# Performance

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

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

**Page:** 119

---

## [Benchmarking Julia vs. Python vs. R with PyCall and RCall](https://discourse.julialang.org/t/benchmarking-julia-vs-python-vs-r-with-pycall-and-rcall/37308)

<div class="topic-metadata">

**Author:** [@mthelm85](https://discourse.julialang.org/u/mthelm85)\
**Replies:** 3\
**Last updated:** [April 10, 2020, 7:09am UTC](https://discourse.julialang.org/t/benchmarking-julia-vs-python-vs-r-with-pycall-and-rcall/37308 "2020-04-10T07:09:58Z")

</div>

I’m putting together an Intro to Julia Jupyter notebook and in my section on Why you should learn Julia I’m emphasizing Julia’s performance. This notebook is for colleagues of mine who primarily use R and a few that use …

---

## [Efficient way for looping over off-diagonal terms](https://discourse.julialang.org/t/efficient-way-for-looping-over-off-diagonal-terms/37282)

<div class="topic-metadata">

**Author:** [@jmcastro2109](https://discourse.julialang.org/u/jmcastro2109)\
**Replies:** 4\
**Last updated:** [April 9, 2020, 6:37pm UTC](https://discourse.julialang.org/t/efficient-way-for-looping-over-off-diagonal-terms/37282 "2020-04-09T18:37:54Z")

</div>

Hello, What is the most efficient way of doing the following double loop? function test(N,T) νtemp = rand(N,T) v = zeros(N,T) println(νtemp) @inbounds for n=1:N, t=1:T ν\[n,t\] = νtemp\[n,t\] …

---

## [Sum operations between arrays](https://discourse.julialang.org/t/sum-operations-between-arrays/37066)

<div class="topic-metadata">

**Author:** [@jmaffi](https://discourse.julialang.org/u/jmaffi)\
**Replies:** 21\
**Last updated:** [April 7, 2020, 4:33pm UTC](https://discourse.julialang.org/t/sum-operations-between-arrays/37066 "2020-04-07T16:33:46Z")

</div>

Hello there, I was wondering if you knew how to efficiently compute the following matrices in Julia. In Matlab I am getting the result 3-6x faster than in Julia, which makes me think that there is room for improvement p…

---

## [Currying and constant propagation, Base.@pure](https://discourse.julialang.org/t/currying-and-constant-propagation-base-pure/36908)

<div class="topic-metadata">

**Author:** [@AndiMD](https://discourse.julialang.org/u/AndiMD)\
**Replies:** 4\
**Last updated:** [April 3, 2020, 6:02pm UTC](https://discourse.julialang.org/t/currying-and-constant-propagation-base-pure/36908 "2020-04-03T18:02:03Z")

</div>

Dear Julians, I have a generic model function with many parameters. I want to hold subsets of these parameters constant, and obtain well-specialized methods on a reduced parameter set. Unfortunately, in many cases, no …

---

## [Slow performance with Julia on optimization problems](https://discourse.julialang.org/t/slow-performance-with-julia-on-optimization-problems/36917)

<div class="topic-metadata">

**Author:** [@bandaya](https://discourse.julialang.org/u/bandaya)\
**Replies:** 2\
**Last updated:** [April 3, 2020, 5:20pm UTC](https://discourse.julialang.org/t/slow-performance-with-julia-on-optimization-problems/36917 "2020-04-03T17:20:54Z")

</div>

I am getting slow performance with JuliaDB when I run optimization problems. I store data for all simulations in one CSV file for each set of data, and then filter it for the relevant simulation and make a call to the op…

---

## [Running small functions bundled in an outer function taking twice the time of running them separately](https://discourse.julialang.org/t/running-small-functions-bundled-in-an-outer-function-taking-twice-the-time-of-running-them-separately/36894)

<div class="topic-metadata">

**Author:** [@atrabattoni](https://discourse.julialang.org/u/atrabattoni)\
**Replies:** 7\
**Last updated:** [April 2, 2020, 4:06pm UTC](https://discourse.julialang.org/t/running-small-functions-bundled-in-an-outer-function-taking-twice-the-time-of-running-them-separately/36894 "2020-04-02T16:06:39Z")

</div>

I’m working on optimizing some code. I isolated small functions, I benchmarked them and I was happy with their speed. But when I bundle those functions in an outer function, the timing almost twice the sum of the isolate…

---

## [Cell list algorithm is slower than double for loop](https://discourse.julialang.org/t/cell-list-algorithm-is-slower-than-double-for-loop/36621)

<div class="topic-metadata">

**Author:** [@Maize](https://discourse.julialang.org/u/Maize)\
**Replies:** 18\
**Last updated:** [April 2, 2020, 1:58pm UTC](https://discourse.julialang.org/t/cell-list-algorithm-is-slower-than-double-for-loop/36621 "2020-04-02T13:58:44Z")

</div>

I want to solve the fixed radius near neighbor problem, i.e., for a given point set in 2D, find all the point pairs whose length is less than a given radius r. I use the cell list algorithm, see Cell List algorithm and…

---

## [Fast derivatives for tensor expressions using ForwardDiff](https://discourse.julialang.org/t/fast-derivatives-for-tensor-expressions-using-forwarddiff/36840)

<div class="topic-metadata">

**Author:** [@rrhiemstra](https://discourse.julialang.org/u/rrhiemstra)\
**Replies:** 1\
**Last updated:** [April 2, 2020, 9:03am UTC](https://discourse.julialang.org/t/fast-derivatives-for-tensor-expressions-using-forwarddiff/36840 "2020-04-02T09:03:23Z")

</div>

I want to evaluate and differentiate functions on a grid of points that have an underlying tensor structure g(x,y) = Lᵢ(xₖ) Aᵢⱼ Lⱼ(yₗ) Here x = \[x₁, …, xₙ\] and y = \[x₁, …, xₙ\] Here A is a n x n Matrix of coefficien…

---

## [Julia Markdown: Error converting document to pdf. Try running latex manually](https://discourse.julialang.org/t/julia-markdown-error-converting-document-to-pdf-try-running-latex-manually/12342)

<div class="topic-metadata">

**Author:** [@mvcavalcanti](https://discourse.julialang.org/u/mvcavalcanti)\
**Replies:** 2\
**Last updated:** [April 2, 2020, 12:53am UTC](https://discourse.julialang.org/t/julia-markdown-error-converting-document-to-pdf-try-running-latex-manually/12342 "2020-04-02T00:53:30Z")

</div>

I have been using Weave to generate PDFs from Julia markdown, but it is not working. If I run using Weave weave(“gadfly\_md\_sample.jmd”; doctype=“md2pdf”, latex\_cmd=“pdflatex”) I get the following warning: WARNING: E…

---

## [Allocations when constructing a matrix from columns](https://discourse.julialang.org/t/allocations-when-constructing-a-matrix-from-columns/36795)

<div class="topic-metadata">

**Author:** [@mht](https://discourse.julialang.org/u/mht)\
**Replies:** 35\
**Last updated:** [April 1, 2020, 2:12pm UTC](https://discourse.julialang.org/t/allocations-when-constructing-a-matrix-from-columns/36795 "2020-04-01T14:12:51Z")

</div>

Hey all! I’m constructing a matrix from another matrix like this: shapematrix(xs) = \[xs\[:,1\].-xs\[:,4\] xs\[:,2\].-xs\[:,4\] xs\[:,3\].-xs\[:,4\]\] This is somewhat in an inner loop of my program, and I would like to reduce th…

---

## [Images imfilter performance drops when using ImageView](https://discourse.julialang.org/t/images-imfilter-performance-drops-when-using-imageview/36630)

<div class="topic-metadata">

**Author:** [@wizebt](https://discourse.julialang.org/u/wizebt)\
**Replies:** 2\
**Last updated:** [March 31, 2020, 10:35am UTC](https://discourse.julialang.org/t/images-imfilter-performance-drops-when-using-imageview/36630 "2020-03-31T10:35:03Z")

</div>

Hi, imfilter exibit a huge variable performance drop when used in conjonction with ImageView. Here is the test code: using Images # ImageView function test\_imfilter() gk = Kernel.gaussian(2.0f0) I = rand(Float32,1…

---

## [How to get a sub matrix of a large sparse matrix / array efficiently?](https://discourse.julialang.org/t/how-to-get-a-sub-matrix-of-a-large-sparse-matrix-array-efficiently/36741)

<div class="topic-metadata">

**Author:** [@mlanghinrichs](https://discourse.julialang.org/u/mlanghinrichs)\
**Replies:** 11\
**Last updated:** [March 30, 2020, 8:51pm UTC](https://discourse.julialang.org/t/how-to-get-a-sub-matrix-of-a-large-sparse-matrix-array-efficiently/36741 "2020-03-30T20:51:04Z")

</div>

Hi all, I have a large sparse matrix / 2-d-array, some random indices and want to obtain a sub matrix of the large sparse matrix for these random indices. I noticed that a view() is quite fast for doing this (order of ~…

---

## [What LLVM version to use, 10, 11 possible? And how to reduce startup time (for the Benchmark Game)?](https://discourse.julialang.org/t/what-llvm-version-to-use-10-11-possible-and-how-to-reduce-startup-time-for-the-benchmark-game/36743)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 3\
**Last updated:** [March 30, 2020, 4:03pm UTC](https://discourse.julialang.org/t/what-llvm-version-to-use-10-11-possible-and-how-to-reduce-startup-time-for-the-benchmark-game/36743 "2020-03-30T16:03:32Z")

</div>

A. I know I’m using LLVM 9.0.1, but is latest 10 (or 11) coming to master? I’m just curious if Julia will optimize better (it’s already good, better than C), no rush. It seems JuliaLang/julia uses LLVM, not LLVM from …

---

## [AOT compilation (not to create an executable)](https://discourse.julialang.org/t/aot-compilation-not-to-create-an-executable/36461)

<div class="topic-metadata">

**Author:** [@tencnivel](https://discourse.julialang.org/u/tencnivel)\
**Replies:** 3\
**Last updated:** [March 29, 2020, 6:48pm UTC](https://discourse.julialang.org/t/aot-compilation-not-to-create-an-executable/36461 "2020-03-29T18:48:33Z")

</div>

I try to improve the deployment of the new releases of my Julia web apps. As of now, the users encounter some lags (and sometimes timeouts) every time I deploy a new version because of the JIT compilation. This gets ev…

---

## [Repeatedly multiplying a Float64 is fastest in chunks of \<51 terms](https://discourse.julialang.org/t/repeatedly-multiplying-a-float64-is-fastest-in-chunks-of-51-terms/36527)

<div class="topic-metadata">

**Author:** [@frank](https://discourse.julialang.org/u/frank)\
**Replies:** 11\
**Last updated:** [March 28, 2020, 3:26pm UTC](https://discourse.julialang.org/t/repeatedly-multiplying-a-float64-is-fastest-in-chunks-of-51-terms/36527 "2020-03-28T15:26:51Z")

</div>

I’ve written a fast Julia-only permutation (n P r) function intended for perms small enough to fit into a Float64 (at the expense of some precision). Thus, if a permutation doesn’t exceed 1.7976931348623157e308, one can …

---

## [Variation in computation time for execution of the exact same code](https://discourse.julialang.org/t/variation-in-computation-time-for-execution-of-the-exact-same-code/36333)

<div class="topic-metadata">

**Author:** [@jleman](https://discourse.julialang.org/u/jleman)\
**Replies:** 35\
**Last updated:** [March 27, 2020, 6:57pm UTC](https://discourse.julialang.org/t/variation-in-computation-time-for-execution-of-the-exact-same-code/36333 "2020-03-27T18:57:38Z")

</div>

I have a block of code (about 1000 lines) that performs electromagnetic computation. The code is executed multiple times with random variation of key input variables. Out of curiosity I set the input variables to be th…

---

## [Operating on many arrays of the same size: one loop, many loops, or broadcasting?](https://discourse.julialang.org/t/operating-on-many-arrays-of-the-same-size-one-loop-many-loops-or-broadcasting/36608)

<div class="topic-metadata">

**Author:** [@Dr.Merkwuedigliebe](https://discourse.julialang.org/u/Dr.Merkwuedigliebe)\
**Replies:** 3\
**Last updated:** [March 27, 2020, 6:22pm UTC](https://discourse.julialang.org/t/operating-on-many-arrays-of-the-same-size-one-loop-many-loops-or-broadcasting/36608 "2020-03-27T18:22:25Z")

</div>

I am working on a physical-process simulation, set on a large spatial grid. Each cell of the grid contains a set variables representing the status of the model. Let’s say the variables are a, b, c, d, and e, stored as ar…

---

## [Strange allocations during broadcasting](https://discourse.julialang.org/t/strange-allocations-during-broadcasting/26605)

<div class="topic-metadata">

**Author:** [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Replies:** 13\
**Last updated:** [March 25, 2020, 6:20pm UTC](https://discourse.julialang.org/t/strange-allocations-during-broadcasting/26605 "2020-03-25T18:20:45Z")

</div>

Can you please explain me why in the following code the second broadcasting results in 3 allocations? using BenchmarkTools u = rand(100) k1 = similar(u) k2 = similar(u) k3 = similar(u) k4 = similar(u) @btime @. $u = $…

---

## [Strange comportment of @distributed](https://discourse.julialang.org/t/strange-comportment-of-distributed/36409)

<div class="topic-metadata">

**Author:** [@Geoffrey](https://discourse.julialang.org/u/Geoffrey)\
**Replies:** 4\
**Last updated:** [March 25, 2020, 3:43pm UTC](https://discourse.julialang.org/t/strange-comportment-of-distributed/36409 "2020-03-25T15:43:11Z")

</div>

Hi, I’m not use to write down question but I’ve long search on google and I can’t find answer to my problem. I trying to implement the algorithm of sugimoto et al concerning Compressive Bilateral Filter (DOI: 10.1109/TI…

---

## [A lot of memory allocations which I do not understand](https://discourse.julialang.org/t/a-lot-of-memory-allocations-which-i-do-not-understand/36381)

<div class="topic-metadata">

**Author:** [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Replies:** 2\
**Last updated:** [March 23, 2020, 9:39am UTC](https://discourse.julialang.org/t/a-lot-of-memory-allocations-which-i-do-not-understand/36381 "2020-03-23T09:39:06Z")

</div>

I try to mimic the DifferentialEquations.jl solver where, as an example, I consider out of place second order Runge-Kutta method. The code below is the content of the .mem file obtained by running Julia with “–track-allo…

---

## [Parallelization from v1.1.1 to v1.4](https://discourse.julialang.org/t/parallelization-from-v1-1-1-to-v1-4/36365)

<div class="topic-metadata">

**Author:** [@swishmas](https://discourse.julialang.org/u/swishmas)\
**Replies:** 0\
**Last updated:** [March 22, 2020, 9:04pm UTC](https://discourse.julialang.org/t/parallelization-from-v1-1-1-to-v1-4/36365 "2020-03-22T21:04:00Z")

</div>

I just want to know if I missed anything or if there’s a future fix planned. I have code written in v1.1.1 that uses a lot of the multi-threading parallelization listed here When v1.2 and v1.3 came out, there was an att…

---

## [Why is this closure over keyword arguments causing such a dramatic slowdown?](https://discourse.julialang.org/t/why-is-this-closure-over-keyword-arguments-causing-such-a-dramatic-slowdown/36308)

<div class="topic-metadata">

**Author:** [@anon32405968](https://discourse.julialang.org/u/anon32405968)\
**Replies:** 19\
**Last updated:** [March 22, 2020, 8:43pm UTC](https://discourse.julialang.org/t/why-is-this-closure-over-keyword-arguments-causing-such-a-dramatic-slowdown/36308 "2020-03-22T20:43:15Z")

</div>

I’m writing a function that allows a user to freeze some variables of a function (needs to be generic with respect to the names and number of keyword arguments). Design-wise, I now have exactly what I need and the code i…

---

## [How do I lessen memory allocation and speedup block inverse?](https://discourse.julialang.org/t/how-do-i-lessen-memory-allocation-and-speedup-block-inverse/36273)

<div class="topic-metadata">

**Author:** [@the\_daemon\_lord](https://discourse.julialang.org/u/the_daemon_lord)\
**Replies:** 2\
**Last updated:** [March 20, 2020, 9:38pm UTC](https://discourse.julialang.org/t/how-do-i-lessen-memory-allocation-and-speedup-block-inverse/36273 "2020-03-20T21:38:20Z")

</div>

Hello! I was trying to implement block inverses in Julia and noticed that in some cases it’s faster than the builtin inv() but it also allocates way more memory. Is there any way to improve this function? This is my im…

---

## [Questions about Julia Compilation Optimization Levels](https://discourse.julialang.org/t/questions-about-julia-compilation-optimization-levels/11296)

<div class="topic-metadata">

**Author:** [@jinliangwei](https://discourse.julialang.org/u/jinliangwei)\
**Replies:** 3\
**Last updated:** [March 19, 2020, 4:15pm UTC](https://discourse.julialang.org/t/questions-about-julia-compilation-optimization-levels/11296 "2020-03-19T16:15:38Z")

</div>

I couldn’t find documentation on optimization flags. Is there such a documentation? I know one can pass optimization flags (e.g. O0) when calling Julia. Is this O0 the same as Clang’s O0? What is the default optimizati…

---

## [Do rules for good problems for benchmarking Julia exists?](https://discourse.julialang.org/t/do-rules-for-good-problems-for-benchmarking-julia-exists/35900)

<div class="topic-metadata">

**Author:** [@KZiemian](https://discourse.julialang.org/u/KZiemian)\
**Replies:** 9\
**Last updated:** [March 19, 2020, 2:54pm UTC](https://discourse.julialang.org/t/do-rules-for-good-problems-for-benchmarking-julia-exists/35900 "2020-03-19T14:54:40Z")

</div>

Few times I read discussions here, where someone try to check Julia speed, but take problem that was ill-suited for that. Two examples. Some times ago one person post examples in which for loop compute sum of arithmetic …

---

## [Great paper on performance and hardware](https://discourse.julialang.org/t/great-paper-on-performance-and-hardware/36093)

<div class="topic-metadata">

**Author:** [@jakobnissen](https://discourse.julialang.org/u/jakobnissen)\
**Replies:** 2\
**Last updated:** [March 17, 2020, 10:50am UTC](https://discourse.julialang.org/t/great-paper-on-performance-and-hardware/36093 "2020-03-17T10:50:41Z")

</div>

About 6 months back, a user on Slack posted a great paper on coding optimization. It was very long and went into detail on all relevant aspects of how RAM and CPUs work. Can anyone remember the name of it? Already answe…

---

## [Efficient way of comparing two matrices](https://discourse.julialang.org/t/efficient-way-of-comparing-two-matrices/36044)

<div class="topic-metadata">

**Author:** [@jmcastro2109](https://discourse.julialang.org/u/jmcastro2109)\
**Replies:** 4\
**Last updated:** [March 17, 2020, 9:35am UTC](https://discourse.julialang.org/t/efficient-way-of-comparing-two-matrices/36044 "2020-03-17T09:35:45Z")

</div>

Hello, this question might seem very naive. But what is the best way of doing a logical comparison of two matrices. Consider the following MWE: function compare(N) for n=1:N X=rand(\[0,1\],4,4) Y=rand(…

---

## [Global sensitivity analysis Morris Method](https://discourse.julialang.org/t/global-sensitivity-analysis-morris-method/35967)

<div class="topic-metadata">

**Author:** [@vijaya](https://discourse.julialang.org/u/vijaya)\
**Replies:** 0\
**Last updated:** [March 14, 2020, 2:06pm UTC](https://discourse.julialang.org/t/global-sensitivity-analysis-morris-method/35967 "2020-03-14T14:06:04Z")

</div>

Hi In the global sensitvity analysis Morris method example (Lotka Volterra gsa), the input arguments are “total\_num\_trajectory=1000,num\_trajectory=150” The number of parameters in the equations are 4 so generally in t…

---

## [Am I using DiffResults.jl correctly?](https://discourse.julialang.org/t/am-i-using-diffresults-jl-correctly/35894)

<div class="topic-metadata">

**Author:** [@jlchan](https://discourse.julialang.org/u/jlchan)\
**Replies:** 7\
**Last updated:** [March 14, 2020, 5:06am UTC](https://discourse.julialang.org/t/am-i-using-diffresults-jl-correctly/35894 "2020-03-14T05:06:41Z")

</div>

I’m trying to compute Jacobian and function values simultaneously using ForwardDiff.jl. A simple MWE example is using StaticArrays using ForwardDiff using DiffResults using BenchmarkTools f(x) = SVector((@. x\[1\]\*x\[2\])…

---

## [Why is python faster than Julia](https://discourse.julialang.org/t/why-is-python-faster-than-julia/35890)

<div class="topic-metadata">

**Author:** [@adangreen](https://discourse.julialang.org/u/adangreen)\
**Replies:** 14\
**Last updated:** [March 12, 2020, 11:34pm UTC](https://discourse.julialang.org/t/why-is-python-faster-than-julia/35890 "2020-03-12T23:34:27Z")

</div>

I wrote two absolutely identical pieces of code on python and Julia: from time import time start\_time = time() def euclidian\_algorithm\_division\_count(a, b): division\_count = 1 if b \> a: a, b = b, a …

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

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