# Performance

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

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

**Page:** 140

---

## [Looping over float-range is faster than looping over int-range?](https://discourse.julialang.org/t/looping-over-float-range-is-faster-than-looping-over-int-range/13704)

<div class="topic-metadata">

**Author:** [@DNF](https://discourse.julialang.org/u/DNF)\
**Replies:** 9\
**Last updated:** [August 19, 2018, 9:30pm UTC](https://discourse.julialang.org/t/looping-over-float-range-is-faster-than-looping-over-int-range/13704 "2018-08-19T21:30:25Z")

</div>

I came across a micro-benchmark online, with some weird performance characteristics. Here is the function, benchmarking on MacOS, Julia version 1.0.0: function g(N) s = 0. for k = 1:N+1 s = s + (-1)^(k+…

---

## [Varargs performance](https://discourse.julialang.org/t/varargs-performance/13578)

<div class="topic-metadata">

**Author:** [@alee](https://discourse.julialang.org/u/alee)\
**Replies:** 5\
**Last updated:** [August 18, 2018, 3:49pm UTC](https://discourse.julialang.org/t/varargs-performance/13578 "2018-08-18T15:49:10Z")

</div>

I’m experiencing some poor performance when using varargs. I can work around it by writing more code, but would really like to understand what the specific issue is. Here is an attempt at a minimal working example, indi…

---

## [Hot loop updating array elements with product over other array](https://discourse.julialang.org/t/hot-loop-updating-array-elements-with-product-over-other-array/13609)

<div class="topic-metadata">

**Author:** [@stst](https://discourse.julialang.org/u/stst)\
**Replies:** 15\
**Last updated:** [August 17, 2018, 10:05pm UTC](https://discourse.julialang.org/t/hot-loop-updating-array-elements-with-product-over-other-array/13609 "2018-08-17T22:05:22Z")

</div>

How can one improve performance of the following MWE (using 1.0.0)? function bg\_sim\_mwe(nB=100,nSamples=100) e = 0.9 p = 0.8 nt = 100 t = range(0,stop=5.0,length=nt) V(ph) = 1.0 - p + p\*(cos(ph) +…

---

## [Too many allocations when indexing with slices](https://discourse.julialang.org/t/too-many-allocations-when-indexing-with-slices/13532)

<div class="topic-metadata">

**Author:** [@noahstier](https://discourse.julialang.org/u/noahstier)\
**Replies:** 16\
**Last updated:** [August 17, 2018, 11:07am UTC](https://discourse.julialang.org/t/too-many-allocations-when-indexing-with-slices/13532 "2018-08-17T11:07:23Z")

</div>

The following code contains two equivalent implementations of a trivial algorithm. slow\_func uses vectorized indexing and assignment while fast\_func individually indexes and assigns each array element in a loop. Can any…

---

## [Naive matrix multiplication is super slow in Julia 1.0?](https://discourse.julialang.org/t/naive-matrix-multiplication-is-super-slow-in-julia-1-0/13589)

<div class="topic-metadata">

**Author:** [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Replies:** 12\
**Last updated:** [August 17, 2018, 4:21am UTC](https://discourse.julialang.org/t/naive-matrix-multiplication-is-super-slow-in-julia-1-0/13589 "2018-08-17T04:21:21Z")

</div>

I benchmarked the following naive matrix multiplication algorithm in both Julia 0.6 and 1.0. Surprisingly, Julia 1.0 version runs 4 times slower. Doing @code\_llvm shows very neat output in 0.6 vs. 1.0. Any idea what is g…

---

## [A bet: what specific algorithms in Julia can be faster or as fast as C++ implementations?](https://discourse.julialang.org/t/a-bet-what-specific-algorithms-in-julia-can-be-faster-or-as-fast-as-c-implementations/13564)

<div class="topic-metadata">

**Author:** [@sairus7](https://discourse.julialang.org/u/sairus7)\
**Replies:** 12\
**Last updated:** [August 16, 2018, 4:22pm UTC](https://discourse.julialang.org/t/a-bet-what-specific-algorithms-in-julia-can-be-faster-or-as-fast-as-c-implementations/13564 "2018-08-16T16:22:31Z")

</div>

Me and my colleague have made a bet that Julia can be faster than C++ in several test cases. I will write a set of algorithms in Julia, and he will write the same algorithms in C++, then we will measure the performance. …

---

## [Strange performance with Adjoint structures](https://discourse.julialang.org/t/strange-performance-with-adjoint-structures/13397)

<div class="topic-metadata">

**Author:** [@anon94023334](https://discourse.julialang.org/u/anon94023334)\
**Replies:** 7\
**Last updated:** [August 14, 2018, 6:12pm UTC](https://discourse.julialang.org/t/strange-performance-with-adjoint-structures/13397 "2018-08-14T18:12:35Z")

</div>

julia\> a = sprand(Int16, 10000, 10000, 0.2); julia\> y = a'; julia\> @time y\[3,:\]; 0.001126 seconds (28 allocations: 41.156 KiB) julia\> @time y.parent\[:,3\]; 0.000013 seconds (7 allocations: 19.625 KiB) julia\> y\[3,:…

---

## [Calculate FFT on GPU for every row of a 2D array](https://discourse.julialang.org/t/calculate-fft-on-gpu-for-every-row-of-a-2d-array/13042)

<div class="topic-metadata">

**Author:** [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Replies:** 2\
**Last updated:** [August 14, 2018, 11:18am UTC](https://discourse.julialang.org/t/calculate-fft-on-gpu-for-every-row-of-a-2d-array/13042 "2018-08-14T11:18:44Z")

</div>

Hello, I have a 2D array and I want to calculate FFT for every raw of this array. I try to do it on GPU using CuArrays, but my GPU version of the code is too slow because of multiple memory allocations that I do not kno…

---

## [slow performance of eig](https://discourse.julialang.org/t/slow-performance-of-eig/13074)

<div class="topic-metadata">

**Author:** [@itzui](https://discourse.julialang.org/u/itzui)\
**Replies:** 14\
**Last updated:** [August 14, 2018, 5:39am UTC](https://discourse.julialang.org/t/slow-performance-of-eig/13074 "2018-08-14T05:39:40Z")

</div>

Hello, the performance of the determination of the eigenvalues and the eigenvector for small complex matrices in Julia seems for me quite slow. If I use the following code N = 100000 dim = 3 function eigen() for i …

---

## [Performance on different Operating Systems](https://discourse.julialang.org/t/performance-on-different-operating-systems/13131)

<div class="topic-metadata">

**Author:** [@CiaranOMara](https://discourse.julialang.org/u/CiaranOMara)\
**Replies:** 1\
**Last updated:** [August 10, 2018, 3:24pm UTC](https://discourse.julialang.org/t/performance-on-different-operating-systems/13131 "2018-08-10T15:24:20Z")

</div>

Has Julia been benchmarked on different Operating Systems?

---

## [Optimization of array views](https://discourse.julialang.org/t/optimization-of-array-views/13044)

<div class="topic-metadata">

**Author:** [@aashish01](https://discourse.julialang.org/u/aashish01)\
**Replies:** 6\
**Last updated:** [August 8, 2018, 7:42pm UTC](https://discourse.julialang.org/t/optimization-of-array-views/13044 "2018-08-08T19:42:07Z")

</div>

Consider the following code A = rand(1000,20); res = zeros(size(A,1)); @time for i in 1:size(A,1) p = view(A, i, :) res\[i\] = sum(p) end 0.004405 seconds (21.94 k allocations: 436.531 KiB) Note the number of allocati…

---

## [Efficient finite difference operators](https://discourse.julialang.org/t/efficient-finite-difference-operators/12439)

<div class="topic-metadata">

**Author:** [@milankl](https://discourse.julialang.org/u/milankl)\
**Replies:** 19\
**Last updated:** [August 8, 2018, 4:17am UTC](https://discourse.julialang.org/t/efficient-finite-difference-operators/12439 "2018-08-08T04:17:50Z")

</div>

Hey there, I have a model that spends most time in functions like this function Gux!(dudx::Matrix{Numtype},u::Matrix{Numtype}) dudx\[1:end-1,:\] = u\[2:end,:\]-u\[1:end-1,:\] dudx\[end,:\] = u\[1,:\]-u\[end,:\]\` end tha…

---

## [Tests do not start after some minutes](https://discourse.julialang.org/t/tests-do-not-start-after-some-minutes/12503)

<div class="topic-metadata">

**Author:** [@wbhart](https://discourse.julialang.org/u/wbhart)\
**Replies:** 2\
**Last updated:** [August 7, 2018, 1:37pm UTC](https://discourse.julialang.org/t/tests-do-not-start-after-some-minutes/12503 "2018-08-07T13:37:34Z")

</div>

I’m trying to run the test suite for the AbstractAlgebra.jl package with 0.7-beta2, but after many minutes, the first test has not started to run. This is probably due to us doing something stupid that is hampering perf…

---

## [Struggling with type stability - is SMatrix type stable?](https://discourse.julialang.org/t/struggling-with-type-stability-is-smatrix-type-stable/12951)

<div class="topic-metadata">

**Author:** [@GlenHenshaw](https://discourse.julialang.org/u/GlenHenshaw)\
**Replies:** 9\
**Last updated:** [August 6, 2018, 7:33pm UTC](https://discourse.julialang.org/t/struggling-with-type-stability-is-smatrix-type-stable/12951 "2018-08-06T19:33:55Z")

</div>

I have a problem where I want to collect an Array of vectors as I perform an iteration. Something like this: function foo(x::Vector{Float64}, size::Int8) tmat = SMatrix{4,4}{Float64}(eye(4)) tmatrices = Array{SMatri…

---

## [Seemingly permanent performance degradation after fiddling with command-line options](https://discourse.julialang.org/t/seemingly-permanent-performance-degradation-after-fiddling-with-command-line-options/12944)

<div class="topic-metadata">

**Author:** [@nstgc](https://discourse.julialang.org/u/nstgc)\
**Replies:** 0\
**Last updated:** [August 6, 2018, 3:43pm UTC](https://discourse.julialang.org/t/seemingly-permanent-performance-degradation-after-fiddling-with-command-line-options/12944 "2018-08-06T15:43:06Z")

</div>

Yesterday evening I was working on trying to speed up some functions. Most I was tweaking the regex which provided a 13% speed boost. In an attempt to get more out of it I tried running Julia with different options. Name…

---

## [Real and complex coupled types as parametric types](https://discourse.julialang.org/t/real-and-complex-coupled-types-as-parametric-types/12739)

<div class="topic-metadata">

**Author:** [@jarl](https://discourse.julialang.org/u/jarl)\
**Replies:** 12\
**Last updated:** [August 4, 2018, 10:32pm UTC](https://discourse.julialang.org/t/real-and-complex-coupled-types-as-parametric-types/12739 "2018-08-04T22:32:19Z")

</div>

I want a function that takes two parameters, one (potentially) complex and one real parameter. They should have the same precision / underlying format. I tried the following but get an error I do not understand: julia\> …

---

## [Views performance in Julia 1.0-DEV?](https://discourse.julialang.org/t/views-performance-in-julia-1-0-dev/12871)

<div class="topic-metadata">

**Author:** [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Replies:** 1\
**Last updated:** [August 4, 2018, 10:15pm UTC](https://discourse.julialang.org/t/views-performance-in-julia-1-0-dev/12871 "2018-08-04T22:15:11Z")

</div>

The following function runs 1.5x slower in Julia latest 1.0-DEV, compared to Julia 0.6. The memory allocation is the same but @code\_llvm shows very mysterious code in 1.0-DEV. Any idea what is going on? using BenchmarkT…

---

## [Efficiency of converting from Array{Float64} to Array{Float32}](https://discourse.julialang.org/t/efficiency-of-converting-from-array-float64-to-array-float32/12867)

<div class="topic-metadata">

**Author:** [@GlenHenshaw](https://discourse.julialang.org/u/GlenHenshaw)\
**Replies:** 4\
**Last updated:** [August 3, 2018, 8:28pm UTC](https://discourse.julialang.org/t/efficiency-of-converting-from-array-float64-to-array-float32/12867 "2018-08-03T20:28:57Z")

</div>

I’m writing some numeric code that interfaces with a C library, and there are some type conversions that I have to do in order for the interface to work right. Profiling this code yielded a result that was surprising (to…

---

## [Julia is unable to load CSV files from the Kaggle competition](https://discourse.julialang.org/t/julia-is-unable-to-load-csv-files-from-the-kaggle-competition/12830)

<div class="topic-metadata">

**Author:** [@Altaf\_Sultanji](https://discourse.julialang.org/u/Altaf_Sultanji)\
**Replies:** 6\
**Last updated:** [August 3, 2018, 3:47pm UTC](https://discourse.julialang.org/t/julia-is-unable-to-load-csv-files-from-the-kaggle-competition/12830 "2018-08-03T15:47:17Z")

</div>

I am using Julia (v0.6.4) to load csv files. These files can be found at this link: Julia is unable to load them (train.csv and test.csv). I tried to use the CSV package with method CSV.read. While in Python using pan…

---

## [Why do these two functions benchmark the same?](https://discourse.julialang.org/t/why-do-these-two-functions-benchmark-the-same/12831)

<div class="topic-metadata">

**Author:** [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Replies:** 2\
**Last updated:** [August 3, 2018, 2:58am UTC](https://discourse.julialang.org/t/why-do-these-two-functions-benchmark-the-same/12831 "2018-08-03T02:58:01Z")

</div>

I’m running some string comparisons using StringDistances and have written some simple convenience functions that are loosely resembling the extract function in the Python fuzzywuzzy package. Essentially they compare a s…

---

## [Different timing results when putting tic() toc() inside or outside a function](https://discourse.julialang.org/t/different-timing-results-when-putting-tic-toc-inside-or-outside-a-function/12806)

<div class="topic-metadata">

**Author:** [@Norman](https://discourse.julialang.org/u/Norman)\
**Replies:** 2\
**Last updated:** [August 2, 2018, 5:34am UTC](https://discourse.julialang.org/t/different-timing-results-when-putting-tic-toc-inside-or-outside-a-function/12806 "2018-08-02T05:34:47Z")

</div>

Here is a minimal working example to illustrate what I am trying to ask: function test(n::Int) tic() i = 0 while (i \<= n) A = randn(100,100) B = randn(100,100) C = A\*B i+=1 end toc() end test(100) I al…

---

## [Weave pkg to produce reports in Julia](https://discourse.julialang.org/t/weave-pkg-to-produce-reports-in-julia/12796)

<div class="topic-metadata">

**Author:** [@mvcavalcanti](https://discourse.julialang.org/u/mvcavalcanti)\
**Replies:** 7\
**Last updated:** [August 1, 2018, 9:56pm UTC](https://discourse.julialang.org/t/weave-pkg-to-produce-reports-in-julia/12796 "2018-08-01T21:56:29Z")

</div>

Hi. I’d like to do some reports in Julia as I used to do in R through RMarkdown. I found a pkg called Weave to do the same thing but it seems for me that it is necessary a greater integration with Latex (and also Python…

---

## [Repeated Function Call Leaking Memory](https://discourse.julialang.org/t/repeated-function-call-leaking-memory/12718)

<div class="topic-metadata">

**Author:** [@Juser](https://discourse.julialang.org/u/Juser)\
**Replies:** 3\
**Last updated:** [July 29, 2018, 6:16pm UTC](https://discourse.julialang.org/t/repeated-function-call-leaking-memory/12718 "2018-07-29T18:16:59Z")

</div>

Below is code to compute the gradient of the log likelihood of a conditional logit choice model. When I call the gradient multiple times, I eventually run out of memory, even though everything created within the function…

---

## [Precision issue: (A.+R.-A.-R) do not vanish ?!](https://discourse.julialang.org/t/precision-issue-a-r-a-r-do-not-vanish/12615)

<div class="topic-metadata">

**Author:** [@Lian\_Yunlong](https://discourse.julialang.org/u/Lian_Yunlong)\
**Replies:** 33\
**Last updated:** [July 29, 2018, 1:39pm UTC](https://discourse.julialang.org/t/precision-issue-a-r-a-r-do-not-vanish/12615 "2018-07-29T13:39:50Z")

</div>

N = 1023 A = rand(1000:20000,(N,N)); R = rand(ComplexF64,N,N); println(sum(abs.(A.+R.-A.-R))) println(sum(abs.(R.+A.-R.-A))) On my machine it gives 4.53665288446814e-7 5.0590642786119133e-11 What is happening?

---

## [Performance of length(::String)](https://discourse.julialang.org/t/performance-of-length-string/12672)

<div class="topic-metadata">

**Author:** [@Diego\_Javier\_Zea](https://discourse.julialang.org/u/Diego_Javier_Zea)\
**Replies:** 24\
**Last updated:** [July 28, 2018, 9:49pm UTC](https://discourse.julialang.org/t/performance-of-length-string/12672 "2018-07-28T21:49:09Z")

</div>

Hi! I’ve noticed that length(::String) isn’t a cheap operation in Julia, since it requires to iterate the string. In fact, it’s more expensive than Python len(str), even for unicode strings. Also, length(::String) is sl…

---

## [Avoiding memory allocation for vector operations](https://discourse.julialang.org/t/avoiding-memory-allocation-for-vector-operations/12447)

<div class="topic-metadata">

**Author:** [@jdrugo](https://discourse.julialang.org/u/jdrugo)\
**Replies:** 11\
**Last updated:** [July 25, 2018, 3:26pm UTC](https://discourse.julialang.org/t/avoiding-memory-allocation-for-vector-operations/12447 "2018-07-25T15:26:18Z")

</div>

Hi everyone, I expected this to be a trivial optimization, but am struggling with writing vectorized code that doesn’t allocation memory. Consider the following code: function gram\_schmidt1!{T \<: Real}(U::Matrix{T}) …

---

## [Type instability in complex schurfact](https://discourse.julialang.org/t/type-instability-in-complex-schurfact/12566)

<div class="topic-metadata">

**Author:** [@BenjaminBorn](https://discourse.julialang.org/u/BenjaminBorn)\
**Replies:** 4\
**Last updated:** [July 22, 2018, 11:27am UTC](https://discourse.julialang.org/t/type-instability-in-complex-schurfact/12566 "2018-07-22T11:27:27Z")

</div>

Hello everyone, I’m trying to use a complex Schur decomposition and retrieve the generalized eigenvalues. A very much simplified example is here: const A = complex(randn(10,10)) const B = complex(randn(10,10)) functio…

---

## [Julia's GC vs. Go's GC (and more). Good idea to compile Julia to Go?](https://discourse.julialang.org/t/julias-gc-vs-gos-gc-and-more-good-idea-to-compile-julia-to-go/12496)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 3\
**Last updated:** [July 21, 2018, 4:07pm UTC](https://discourse.julialang.org/t/julias-gc-vs-gos-gc-and-more-good-idea-to-compile-julia-to-go/12496 "2018-07-21T16:07:06Z")

</div>

From the interesting keynote from the International Symposium on Memory Management (ISMM) on June 18, 2018: Again we kept knocking off these O(heap size) stop the world processes. We are talking about an 18Gbyte heap…

---

## [Strange performance of a loop](https://discourse.julialang.org/t/strange-performance-of-a-loop/12504)

<div class="topic-metadata">

**Author:** [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Replies:** 37\
**Last updated:** [July 21, 2018, 9:49am UTC](https://discourse.julialang.org/t/strange-performance-of-a-loop/12504 "2018-07-21T09:49:45Z")

</div>

I’m not sure if this is known and was discussed before, but I noticed a performance difference (20% loss) when using m = size(a,1) for i = 1:m do something a\[i,k\] end than when using the literal constant 3 instead: …

---

## [Static arrays and type stability under map](https://discourse.julialang.org/t/static-arrays-and-type-stability-under-map/12538)

<div class="topic-metadata">

**Author:** [@vlc](https://discourse.julialang.org/u/vlc)\
**Replies:** 8\
**Last updated:** [July 20, 2018, 8:55pm UTC](https://discourse.julialang.org/t/static-arrays-and-type-stability-under-map/12538 "2018-07-20T20:55:38Z")

</div>

Hello, I’ve been surprised by the return type of the mapping of a type stable function on a couple of static arrays. Here is a minimal example, first with regular arrays julia\> n = 4; julia\> bool = rand(Bool, n); ju…

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

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