# Performance

**URL:** https://discourse.julialang.org/c/usage/perf/37.md?page=86

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

**Page:** 87

---

## [Runtime increasing as I do more replications](https://discourse.julialang.org/t/runtime-increasing-as-i-do-more-replications/65850)

<div class="topic-metadata">

**Author:** [@worldgiraffe2](https://discourse.julialang.org/u/worldgiraffe2)\
**Replies:** 4\
**Last updated:** [August 5, 2021, 8:36pm UTC](https://discourse.julialang.org/t/runtime-increasing-as-i-do-more-replications/65850 "2021-08-05T20:36:12Z")

</div>

Hi, I’m a new Julia user and would greatly appreciate your help. Currently, I’m running a simulation with multiple replications, as below glob\_result = \[\] for i in 1:n\_rep Random.seed!(1234+i); model\_result = @…

---

## [Is Union{Missing, Float64} a concrete type?](https://discourse.julialang.org/t/is-union-missing-float64-a-concrete-type/65901)

<div class="topic-metadata">

**Author:** [@fipelle](https://discourse.julialang.org/u/fipelle)\
**Replies:** 3\
**Last updated:** [August 5, 2021, 7:36pm UTC](https://discourse.julialang.org/t/is-union-missing-float64-a-concrete-type/65901 "2021-08-05T19:36:39Z")

</div>

I am optimising part of a small package and I am trying to remove type instabilities. Since I am working with incomplete time series, I am using Union{Missing, Float64} data. I have read online that you want to use concr…

---

## [Rand-based Function Optimization](https://discourse.julialang.org/t/rand-based-function-optimization/65874)

<div class="topic-metadata">

**Author:** [@Ian\_Slagle](https://discourse.julialang.org/u/Ian_Slagle)\
**Replies:** 1\
**Last updated:** [August 5, 2021, 12:53pm UTC](https://discourse.julialang.org/t/rand-based-function-optimization/65874 "2021-08-05T12:53:54Z")

</div>

Given a non-zero UInt8, I would like to randomly and uniformly select the index of a bit that is one. For example, if I get UInt8(14), the bitstring would be 00001110, and thus it would return UInt8(2), UInt8(3), and UIn…

---

## [Runtime dispatch when broadcasting a view indexed with CartesianIndex array](https://discourse.julialang.org/t/runtime-dispatch-when-broadcasting-a-view-indexed-with-cartesianindex-array/65870)

<div class="topic-metadata">

**Author:** [@JohnnyChen94](https://discourse.julialang.org/u/JohnnyChen94)\
**Replies:** 1\
**Last updated:** [August 5, 2021, 10:14am UTC](https://discourse.julialang.org/t/runtime-dispatch-when-broadcasting-a-view-indexed-with-cartesianindex-array/65870 "2021-08-05T10:14:11Z")

</div>

Playing with JETTest.jl and I realize that there exists a runtime dispatch when view, broadcasting, and CartesianIndex array(not CartesianIndices) are used together. But haven’t observed any suspicious performance differ…

---

## [Measuring the time properly for nested for-loops with @parallel](https://discourse.julialang.org/t/measuring-the-time-properly-for-nested-for-loops-with-parallel/65841)

<div class="topic-metadata">

**Author:** [@Rick](https://discourse.julialang.org/u/Rick)\
**Replies:** 2\
**Last updated:** [August 5, 2021, 2:10am UTC](https://discourse.julialang.org/t/measuring-the-time-properly-for-nested-for-loops-with-parallel/65841 "2021-08-05T02:10:15Z")

</div>

Hi, I am trying to measure the total time used to execute a nested for-loops. I used @elapsed but it seems to only return the time used by one of the inner loops. A MWE is as follows: function f(m,n) s = SharedArray…

---

## [Error with parallel sparse array building](https://discourse.julialang.org/t/error-with-parallel-sparse-array-building/65833)

<div class="topic-metadata">

**Author:** [@Thomas](https://discourse.julialang.org/u/Thomas)\
**Replies:** 0\
**Last updated:** [August 4, 2021, 5:46pm UTC](https://discourse.julialang.org/t/error-with-parallel-sparse-array-building/65833 "2021-08-04T17:46:54Z")

</div>

I know that the recommended way to @thread build array is to split the work based on nthreads() and then join the array later. (What I said is the same as the macro @threads.) Nevertheless, in the below each thread shoul…

---

## [Structures containing a function field](https://discourse.julialang.org/t/structures-containing-a-function-field/65696)

<div class="topic-metadata">

**Author:** [@aaraujo71](https://discourse.julialang.org/u/aaraujo71)\
**Replies:** 12\
**Last updated:** [August 3, 2021, 5:50pm UTC](https://discourse.julialang.org/t/structures-containing-a-function-field/65696 "2021-08-03T17:50:46Z")

</div>

I would like to include a function as part of a Julia object (struct). However, when I, for example, execute using BenchmarkTools func(x) = 2\*x^2 struct Test k :: Float64 V :: Array{Float64, 1} fn :: Funct…

---

## [What is the fastest way to turn a 3D array into a vector of 2D arrays?](https://discourse.julialang.org/t/what-is-the-fastest-way-to-turn-a-3d-array-into-a-vector-of-2d-arrays/65729)

<div class="topic-metadata">

**Author:** [@erwanlecarpentier](https://discourse.julialang.org/u/erwanlecarpentier)\
**Replies:** 13\
**Last updated:** [August 3, 2021, 2:56pm UTC](https://discourse.julialang.org/t/what-is-the-fastest-way-to-turn-a-3d-array-into-a-vector-of-2d-arrays/65729 "2021-08-03T14:56:36Z")

</div>

Hi, I wonder what would be the fastest way to turn a 3D array into a vector of 2D arrays. Specifically: the input is an array of size size(inp) = (a, b, c) and I want as output a vector (typeof(out) = Array{Array{UInt8,…

---

## [Populating matrix with elements - improve performance](https://discourse.julialang.org/t/populating-matrix-with-elements-improve-performance/65697)

<div class="topic-metadata">

**Author:** [@stst](https://discourse.julialang.org/u/stst)\
**Replies:** 3\
**Last updated:** [August 2, 2021, 10:27pm UTC](https://discourse.julialang.org/t/populating-matrix-with-elements-improve-performance/65697 "2021-08-02T22:27:58Z")

</div>

Does anybody have suggestions on how to speed up the following MWE? using BenchmarkTools function kernel0(t,r) # MWE K = Array{Float64}(undef,length(t),length(r)) for (it,t\_) in enumerate(t) if t\_ == 0.…

---

## [Help with parallelizing indirect inference estimation](https://discourse.julialang.org/t/help-with-parallelizing-indirect-inference-estimation/64487)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 17\
**Last updated:** [August 2, 2021, 3:32pm UTC](https://discourse.julialang.org/t/help-with-parallelizing-indirect-inference-estimation/64487 "2021-08-02T15:32:56Z")

</div>

I’m trying my hand at estimation via indirect inference, and created this script to experiment. I am wondering what is the best way to parallelize the computation. I think the critical functions are simulate and the line…

---

## [Dispatching by values is very slow - Feature or Problem?](https://discourse.julialang.org/t/dispatching-by-values-is-very-slow-feature-or-problem/65586)

<div class="topic-metadata">

**Author:** [@viraltux](https://discourse.julialang.org/u/viraltux)\
**Replies:** 30\
**Last updated:** [August 2, 2021, 3:13pm UTC](https://discourse.julialang.org/t/dispatching-by-values-is-very-slow-feature-or-problem/65586 "2021-08-02T15:13:05Z")

</div>

After learning in Faster default Base.sort! for Julia about Sorting Networks I thought that we surely must have a package in Julia for that, and surely we do: SortingNetworks.jl The problem is this: using SortingNetwo…

---

## [Identical functions repeated benchmarks show systematic differences](https://discourse.julialang.org/t/identical-functions-repeated-benchmarks-show-systematic-differences/65345)

<div class="topic-metadata">

**Author:** [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Replies:** 37\
**Last updated:** [August 2, 2021, 12:35pm UTC](https://discourse.julialang.org/t/identical-functions-repeated-benchmarks-show-systematic-differences/65345 "2021-08-02T12:35:53Z")

</div>

I’m trying to write and benchmark sorting algorithms, and am having some trouble getting consistent benchmark results. I’ve simplified my problem to defining two identical sorting methods using the interface from base/so…

---

## [Eltypes of \`view\`s](https://discourse.julialang.org/t/eltypes-of-view-s/65606)

<div class="topic-metadata">

**Author:** [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Replies:** 10\
**Last updated:** [August 2, 2021, 3:07am UTC](https://discourse.julialang.org/t/eltypes-of-view-s/65606 "2021-08-02T03:07:10Z")

</div>

Let’s say I have a vector t = \[1, 2, missing\]. And I take sub\_t = view(t, 1:2). I know that no elements sub\_t contain missing values. Is there any way to make the eltype of sub\_t be Int instead of Union{Int, Missing}?

---

## [Why is this @simd loop faster than a while loop even if it has longer assembly?](https://discourse.julialang.org/t/why-is-this-simd-loop-faster-than-a-while-loop-even-if-it-has-longer-assembly/65585)

<div class="topic-metadata">

**Author:** [@louie4825](https://discourse.julialang.org/u/louie4825)\
**Replies:** 6\
**Last updated:** [August 1, 2021, 7:17am UTC](https://discourse.julialang.org/t/why-is-this-simd-loop-faster-than-a-while-loop-even-if-it-has-longer-assembly/65585 "2021-08-01T07:17:25Z")

</div>

Why does @simd here make the loop run faster even if the while version has shorter generated assembly? (Thiscode is part of a prime sieve implementation.) using BenchmarkTools # Auxillary functions begin const \_uint\_b…

---

## [Comparing Numba and Julia for a complex matrix computation](https://discourse.julialang.org/t/comparing-numba-and-julia-for-a-complex-matrix-computation/63703)

<div class="topic-metadata">

**Author:** [@Ordens\_Ritter](https://discourse.julialang.org/u/Ordens_Ritter)\
**Replies:** 29\
**Last updated:** [July 31, 2021, 1:50pm UTC](https://discourse.julialang.org/t/comparing-numba-and-julia-for-a-complex-matrix-computation/63703 "2021-07-31T13:50:07Z")

</div>

I am think about slowly switching from Python to Julia. My main problem is the experience. Some years experience in writing code with python compared to: only read some books about Julia (as ‘Julia High Performance’ by A…

---

## [Multithreading simultaneously in two functions](https://discourse.julialang.org/t/multithreading-simultaneously-in-two-functions/65579)

<div class="topic-metadata">

**Author:** [@vkv](https://discourse.julialang.org/u/vkv)\
**Replies:** 3\
**Last updated:** [July 31, 2021, 12:30pm UTC](https://discourse.julialang.org/t/multithreading-simultaneously-in-two-functions/65579 "2021-07-31T12:30:46Z")

</div>

Is there a way to do use all 9 threads in the following functions? function f1() Threads.@threads for i in 1:3 println("MCMC") println("$(Threads.threadid())") sleep(3.0) end println(…

---

## [Fast f(x) ∂f∂x and ∂2f∂x2](https://discourse.julialang.org/t/fast-f-x-f-x-and-2f-x2/65569)

<div class="topic-metadata">

**Author:** [@longemen3000](https://discourse.julialang.org/u/longemen3000)\
**Replies:** 5\
**Last updated:** [July 30, 2021, 9:51pm UTC](https://discourse.julialang.org/t/fast-f-x-f-x-and-2f-x2/65569 "2021-07-30T21:51:55Z")

</div>

Hi, im trying to make a fast evaluation of the value, first and second derivative, in the least amount of forward passes as possible. i’m using at the moment this function: using DiffResults, StaticArrays, ForwardDiff f…

---

## [Fastest way to print many numbers to text file](https://discourse.julialang.org/t/fastest-way-to-print-many-numbers-to-text-file/65537)

<div class="topic-metadata">

**Author:** [@PeterB](https://discourse.julialang.org/u/PeterB)\
**Replies:** 18\
**Last updated:** [July 30, 2021, 9:51pm UTC](https://discourse.julialang.org/t/fastest-way-to-print-many-numbers-to-text-file/65537 "2021-07-30T21:51:41Z")

</div>

EDIT: I found one speedup myself (see my answer below) but still interested in replies… I have a critical loop which looks like this: for j in 1:about\_1000 x = a\_simple\_calculation() @printf(op, " %g", x) # t…

---

## [Finding row index of matrix](https://discourse.julialang.org/t/finding-row-index-of-matrix/65540)

<div class="topic-metadata">

**Author:** [@juls](https://discourse.julialang.org/u/juls)\
**Replies:** 5\
**Last updated:** [July 30, 2021, 12:15pm UTC](https://discourse.julialang.org/t/finding-row-index-of-matrix/65540 "2021-07-30T12:15:43Z")

</div>

Hi, I have two matrices : b = 6×2 Array{Int64,2}: 0 2 1 4 0 7 1 4 1 5 2 4 and a = 6×2 Array{Int64,2}: 0 2 0 7 1 4 1 4 1 5 2 4 I need to find row index, i of matrix b with respect to a. i.e.…

---

## [Faster default Base.sort! for Julia](https://discourse.julialang.org/t/faster-default-base-sort-for-julia/65508)

<div class="topic-metadata">

**Author:** [@viraltux](https://discourse.julialang.org/u/viraltux)\
**Replies:** 4\
**Last updated:** [July 29, 2021, 9:46pm UTC](https://discourse.julialang.org/t/faster-default-base-sort-for-julia/65508 "2021-07-29T21:46:21Z")

</div>

There are functions like factorial where Julia uses a factorial\_lookup function to directly return results from a table when the value is lower or equal to 20. Playing around with sorting algorithms I built a simple one…

---

## [Julia inner type-inference working](https://discourse.julialang.org/t/julia-inner-type-inference-working/65521)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 2\
**Last updated:** [July 29, 2021, 8:17pm UTC](https://discourse.julialang.org/t/julia-inner-type-inference-working/65521 "2021-07-29T20:17:59Z")

</div>

Hi all, I run over a very surprising type-inference difference. I always thought these two codes would be regarded identical to Julia’s compiler. make\_sigtype\_without\_bits(::Type{T}) where T\<:Tuple = Tuple{\_make\_sigtyp…

---

## [Tullio boundary error for shifted stencil](https://discourse.julialang.org/t/tullio-boundary-error-for-shifted-stencil/65442)

<div class="topic-metadata">

**Author:** [@Chiil](https://discourse.julialang.org/u/Chiil)\
**Replies:** 11\
**Last updated:** [July 29, 2021, 7:05am UTC](https://discourse.julialang.org/t/tullio-boundary-error-for-shifted-stencil/65442 "2021-07-29T07:05:35Z")

</div>

I implemented three versions of a 1D diffusion kernel, two with Tullio. The third version makes errors near the boundary. Is this illegal syntax and if so, can I fix this? I would like to avoid the second method in my ac…

---

## [Fast performance of array comprehension without allocations](https://discourse.julialang.org/t/fast-performance-of-array-comprehension-without-allocations/65352)

<div class="topic-metadata">

**Author:** [@Chiil](https://discourse.julialang.org/u/Chiil)\
**Replies:** 14\
**Last updated:** [July 28, 2021, 8:07pm UTC](https://discourse.julialang.org/t/fast-performance-of-array-comprehension-without-allocations/65352 "2021-07-28T20:07:09Z")

</div>

I have the following code, where the nice and compact array comprehension code is 34x slower (880 ms vs 26 ms) than the written kernel and allocates memory where I would like to prevent this. Is there a way to make the s…

---

## [Julia sets in Julia, using Interact.jl - I'd like to get it faster](https://discourse.julialang.org/t/julia-sets-in-julia-using-interact-jl-id-like-to-get-it-faster/35533)

<div class="topic-metadata">

**Author:** [@zenon](https://discourse.julialang.org/u/zenon)\
**Replies:** 29\
**Last updated:** [July 28, 2021, 8:00pm UTC](https://discourse.julialang.org/t/julia-sets-in-julia-using-interact-jl-id-like-to-get-it-faster/35533 "2021-07-28T20:00:47Z")

</div>

Hi, after I talked about Julia to collegues some weeks ago, I somehow wanted to plot Julia sets (Wikipedia), simply because I thougt it to be a funny example. To play with it I used Interact.jl. The current result is t…

---

## [Applying performance tips in library](https://discourse.julialang.org/t/applying-performance-tips-in-library/65452)

<div class="topic-metadata">

**Author:** [@rvignolo](https://discourse.julialang.org/u/rvignolo)\
**Replies:** 0\
**Last updated:** [July 28, 2021, 4:44pm UTC](https://discourse.julialang.org/t/applying-performance-tips-in-library/65452 "2021-07-28T16:44:37Z")

</div>

Hi all, I have implemented a neutron transport particle code in julia, NeutronTransport.jl, and I want it to be as fast as possible. Specifically, I just wanted to know if someone is interested in helping me implement: …

---

## [Simple Dykstra projection : Could it be faster?](https://discourse.julialang.org/t/simple-dykstra-projection-could-it-be-faster/65432)

<div class="topic-metadata">

**Author:** [@lrnv](https://discourse.julialang.org/u/lrnv)\
**Replies:** 5\
**Last updated:** [July 28, 2021, 3:19pm UTC](https://discourse.julialang.org/t/simple-dykstra-projection-could-it-be-faster/65432 "2021-07-28T15:19:51Z")

</div>

Hi, I’m writting a simple Dykstra sheme for projecting a vector start onto equality constraints Ax = b and inequelity constraints x \>= 0. It works great, but I wander if it could be faster ? Here’s the current version …

---

## [Surprising (?) behaviour of assignment-update operators](https://discourse.julialang.org/t/surprising-behaviour-of-assignment-update-operators/65431)

<div class="topic-metadata">

**Author:** [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Replies:** 8\
**Last updated:** [July 28, 2021, 1:57pm UTC](https://discourse.julialang.org/t/surprising-behaviour-of-assignment-update-operators/65431 "2021-07-28T13:57:29Z")

</div>

It seems like f -= a is actually exactly equivalent to f = f - a. This surprised me because I’d naively expected -= to be update-in-place, so that I wouldn’t need a View when f is an Array slice, but actually it seems I …

---

## [Why does broadcast operation allocate?](https://discourse.julialang.org/t/why-does-broadcast-operation-allocate/65428)

<div class="topic-metadata">

**Author:** [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Replies:** 3\
**Last updated:** [July 28, 2021, 11:06am UTC](https://discourse.julialang.org/t/why-does-broadcast-operation-allocate/65428 "2021-07-28T11:06:21Z")

</div>

Why does this broadcasting allocate? julia\> a = rand(241); b = rand(241); julia\> @time a .-= b; 0.111315 seconds (188.85 k allocations: 11.037 MiB, 99.59% compilation time) julia\> @time a .-= b; 0.000016 seconds (…

---

## [From Float type to Integer](https://discourse.julialang.org/t/from-float-type-to-integer/65392)

<div class="topic-metadata">

**Author:** [@juls](https://discourse.julialang.org/u/juls)\
**Replies:** 1\
**Last updated:** [July 27, 2021, 5:18pm UTC](https://discourse.julialang.org/t/from-float-type-to-integer/65392 "2021-07-27T17:18:15Z")

</div>

Hi, I wanted to obtain integer output instead of float type output from functions: floor(4.56), ceil(4.56). I would be glad to know how to obtain integer output for the same. Also, I read in documentation, interger di…

---

## [How can I find the subset of dataframe that contain elements with Number datatype?](https://discourse.julialang.org/t/how-can-i-find-the-subset-of-dataframe-that-contain-elements-with-number-datatype/65388)

<div class="topic-metadata">

**Author:** [@Manu\_Francis](https://discourse.julialang.org/u/Manu_Francis)\
**Replies:** 2\
**Last updated:** [July 27, 2021, 4:32pm UTC](https://discourse.julialang.org/t/how-can-i-find-the-subset-of-dataframe-that-contain-elements-with-number-datatype/65388 "2021-07-27T16:32:29Z")

</div>

Hi, I am trying to find subset of dataframe having elements with Number datatypes. But I couldn’t find any single function to find the subset. So I have implemented as #df is the dataframe with columns having Number an…

[Previous page](https://discourse.julialang.org/c/usage/perf/37.md?page=85)

[Next page](https://discourse.julialang.org/c/usage/perf/37.md?page=87)
