# Performance

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

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

**Page:** 145

---

## [Eliminite overhead of "invoke" in benchmark](https://discourse.julialang.org/t/eliminite-overhead-of-invoke-in-benchmark/9028)

<div class="topic-metadata">

**Author:** [@goerz](https://discourse.julialang.org/u/goerz)\
**Replies:** 7\
**Last updated:** [February 14, 2018, 3:49am UTC](https://discourse.julialang.org/t/eliminite-overhead-of-invoke-in-benchmark/9028 "2018-02-14T03:49:50Z")

</div>

In my benchmark, I would like to compare the performance of a more specialized method to a less specialized method. Following Ralph Smith’s suggestion, I’ve tried using the invoke function for this. The problem is that …

---

## [Type inference slowdown in binary file i/o](https://discourse.julialang.org/t/type-inference-slowdown-in-binary-file-i-o/8995)

<div class="topic-metadata">

**Author:** [@dataPulverizer](https://discourse.julialang.org/u/dataPulverizer)\
**Replies:** 2\
**Last updated:** [February 11, 2018, 8:17pm UTC](https://discourse.julialang.org/t/type-inference-slowdown-in-binary-file-i-o/8995 "2018-02-11T20:17:13Z")

</div>

I’m writing code to read and write 1D arrays to binary files. I want the read function to infer the element type and read back the data, I had initially a large slowdown that I partially resolved by splitting the read fu…

---

## [Interpretation of memallocs returned by @timed](https://discourse.julialang.org/t/interpretation-of-memallocs-returned-by-timed/8968)

<div class="topic-metadata">

**Author:** [@goerz](https://discourse.julialang.org/u/goerz)\
**Replies:** 0\
**Last updated:** [February 10, 2018, 1:54am UTC](https://discourse.julialang.org/t/interpretation-of-memallocs-returned-by-timed/8968 "2018-02-10T01:54:32Z")

</div>

I was trying to find some information about the memory allocation counters that the @timed macro returns. These should probably be explained in the documentation of @timed. I did find some comments in the source code for…

---

## [Accelerate compiler start time](https://discourse.julialang.org/t/accelerate-compiler-start-time/8951)

<div class="topic-metadata">

**Author:** [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Replies:** 3\
**Last updated:** [February 9, 2018, 2:21pm UTC](https://discourse.julialang.org/t/accelerate-compiler-start-time/8951 "2018-02-09T14:21:05Z")

</div>

I am developing a CLI package CLI.jl, but it seems that the start time of the compiler makes a CLI script slower than a Python script or an executable. (precompile is on) I tried to use static-julia to compile it to an …

---

## [Large Scale Software Design and Guidelines](https://discourse.julialang.org/t/large-scale-software-design-and-guidelines/8925)

<div class="topic-metadata">

**Author:** [@marcello](https://discourse.julialang.org/u/marcello)\
**Replies:** 8\
**Last updated:** [February 9, 2018, 12:17am UTC](https://discourse.julialang.org/t/large-scale-software-design-and-guidelines/8925 "2018-02-09T00:17:33Z")

</div>

I’ve done an application in C++ that is taking some million lines of code. And I’ve paid the price. By starting reading the book ‘Large Scale Software Design - John Lakos’ I can see I made different mistakes, which I d…

---

## [Type-unstable keyword constructor on parameterized type](https://discourse.julialang.org/t/type-unstable-keyword-constructor-on-parameterized-type/8852)

<div class="topic-metadata">

**Author:** [@tomerarnon](https://discourse.julialang.org/u/tomerarnon)\
**Replies:** 5\
**Last updated:** [February 8, 2018, 7:46pm UTC](https://discourse.julialang.org/t/type-unstable-keyword-constructor-on-parameterized-type/8852 "2018-02-08T19:46:27Z")

</div>

I have a parameterized struct for which I would like to define a convenient modifying function which uses a preexisting object of that type. The most convenient and clearest way is obviously to define a keyword construct…

---

## [Methods to reduce gc time?](https://discourse.julialang.org/t/methods-to-reduce-gc-time/8840)

<div class="topic-metadata">

**Author:** [@RandomString123](https://discourse.julialang.org/u/RandomString123)\
**Replies:** 7\
**Last updated:** [February 7, 2018, 2:15pm UTC](https://discourse.julialang.org/t/methods-to-reduce-gc-time/8840 "2018-02-07T14:15:15Z")

</div>

I have finally gotten some code I translated from R working. It is by no means optimized, and it is my first julia code, so I didn’t expect great performance but it is significantly slower than I would have expected. I…

---

## [log(N) algo for sampling from vector](https://discourse.julialang.org/t/log-n-algo-for-sampling-from-vector/8713)

<div class="topic-metadata">

**Author:** [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Replies:** 5\
**Last updated:** [February 7, 2018, 4:59am UTC](https://discourse.julialang.org/t/log-n-algo-for-sampling-from-vector/8713 "2018-02-07T04:59:24Z")

</div>

Hi, I am using the following piece of code using StatsBase pf = StatsBase.Weights(rand(10)) e = sample(pf) Upon using @which sample(pf), one gets sample(wv::StatsBase.AbstractWeights) in StatsBase at .../StatsBase/sr…

---

## [Why is this simple code slow (how to speed it up)](https://discourse.julialang.org/t/why-is-this-simple-code-slow-how-to-speed-it-up/8854)

<div class="topic-metadata">

**Author:** [@cpraveen](https://discourse.julialang.org/u/cpraveen)\
**Replies:** 7\
**Last updated:** [February 6, 2018, 4:44am UTC](https://discourse.julialang.org/t/why-is-this-simple-code-slow-how-to-speed-it-up/8854 "2018-02-06T04:44:42Z")

</div>

This small code takes about 24 seconds every time on my macbook pro. Is there a way to make it faster ? I run it on commend line as julia test.jl using Plots x = linspace(0.0,2\*pi,100); y = sin.(x); plot(x,y) savefig("…

---

## [Reduce views for a function that is applied piece-wise over an array](https://discourse.julialang.org/t/reduce-views-for-a-function-that-is-applied-piece-wise-over-an-array/8806)

<div class="topic-metadata">

**Author:** [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Replies:** 6\
**Last updated:** [February 4, 2018, 3:10pm UTC](https://discourse.julialang.org/t/reduce-views-for-a-function-that-is-applied-piece-wise-over-an-array/8806 "2018-02-04T15:10:32Z")

</div>

I have a function f! that operates in-place in a D dimensional Vector, used in DifferentialEquations. For example @inline @inbounds function f!(du, u, p, t) σ = p\[1\]; ρ = p\[2\]; β = p\[3\] du\[1\] = σ\*(u\[2\]-u\[1\]) …

---

## [Ironic observation about \`sort\` and \`sortperm\` speed for "small integers" vs R](https://discourse.julialang.org/t/ironic-observation-about-sort-and-sortperm-speed-for-small-integers-vs-r/8715)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 32\
**Last updated:** [February 4, 2018, 1:48pm UTC](https://discourse.julialang.org/t/ironic-observation-about-sort-and-sortperm-speed-for-small-integers-vs-r/8715 "2018-02-04T13:48:42Z")

</div>

I found something ironic about sort performance in Julia vs R. I am trying to sort a vector with integer values ranging from 1 to 1\_000\_000. Julia uses counting sort which is much faster than R’s radix sort, but the situ…

---

## [Benchmarks: Julia vs Python+Numba](https://discourse.julialang.org/t/benchmarks-julia-vs-python-numba/8709)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 4\
**Last updated:** [January 31, 2018, 2:45pm UTC](https://discourse.julialang.org/t/benchmarks-julia-vs-python-numba/8709 "2018-01-31T14:45:29Z")

</div>

Just sharing - I started running some reality checks. I hope experiments like this would re-enforce our assessment about Julia’s greatness in performance, as compared to the Python+Numba ecosystem. Only one notebook i…

---

## [fusing not faster](https://discourse.julialang.org/t/fusing-not-faster/8696)

<div class="topic-metadata">

**Author:** [@mvhulten](https://discourse.julialang.org/u/mvhulten)\
**Replies:** 7\
**Last updated:** [January 30, 2018, 5:20pm UTC](https://discourse.julialang.org/t/fusing-not-faster/8696 "2018-01-30T17:20:52Z")

</div>

I just read about fusing and broadcasting. I understood that fusing is faster than other approaches. But I have this code: julia\> a = rand(1, 10000) 1×10000 Array{Float64,2}: 0.975847 0.427092 0.480224 … 0.469955…

---

## [Keeping track of simple vs high-performance versions](https://discourse.julialang.org/t/keeping-track-of-simple-vs-high-performance-versions/8651)

<div class="topic-metadata">

**Author:** [@improbable22](https://discourse.julialang.org/u/improbable22)\
**Replies:** 2\
**Last updated:** [January 30, 2018, 7:57am UTC](https://discourse.julialang.org/t/keeping-track-of-simple-vs-high-performance-versions/8651 "2018-01-30T07:57:56Z")

</div>

Prompted by this Dot function thread, in which I learned about SugarBLAS and InplaceOps and Yeppp… Often it seems that the first implementation of a function is very simple, and then the fast version is quite a bit more …

---

## [Benchmarking tests to ensure PRs don't introduce regressions](https://discourse.julialang.org/t/benchmarking-tests-to-ensure-prs-dont-introduce-regressions/8630)

<div class="topic-metadata">

**Author:** [@anon94023334](https://discourse.julialang.org/u/anon94023334)\
**Replies:** 5\
**Last updated:** [January 28, 2018, 6:44pm UTC](https://discourse.julialang.org/t/benchmarking-tests-to-ensure-prs-dont-introduce-regressions/8630 "2018-01-28T18:44:32Z")

</div>

Has anyone come up with a clever way to perform benchmarking of specific functions as part of the testing or CI process so that PRs can be checked to make sure no performance regressions are introduced?

---

## [View and Slices: comparison of speed](https://discourse.julialang.org/t/view-and-slices-comparison-of-speed/8647)

<div class="topic-metadata">

**Author:** [@SepandMeenu](https://discourse.julialang.org/u/SepandMeenu)\
**Replies:** 4\
**Last updated:** [January 27, 2018, 11:44pm UTC](https://discourse.julialang.org/t/view-and-slices-comparison-of-speed/8647 "2018-01-27T23:44:00Z")

</div>

I measured the speed for mapping a function of several variables on slices and views of arrays. The speed of slicing seems to be higher than views! And using the macro form, @view, increases the speed compared to the e…

---

## [Use QR factorization efficiently](https://discourse.julialang.org/t/use-qr-factorization-efficiently/8615)

<div class="topic-metadata">

**Author:** [@saschatimme](https://discourse.julialang.org/u/saschatimme)\
**Replies:** 12\
**Last updated:** [January 27, 2018, 7:17am UTC](https://discourse.julialang.org/t/use-qr-factorization-efficiently/8615 "2018-01-27T07:17:33Z")

</div>

Hey there, I wanted to solve an overdetermined system Ax=b where A \\in \\mathbb{R}^{m \\times n} and b \\in \\mathbb{R}^{m} with m \< n using the QR decomposition. Since this in a very performance critical part I wanted to …

---

## [Slow down when running several parallel julia processes which use BLAS (MWE is provided)](https://discourse.julialang.org/t/slow-down-when-running-several-parallel-julia-processes-which-use-blas-mwe-is-provided/8400)

<div class="topic-metadata">

**Author:** [@Gregstrq](https://discourse.julialang.org/u/Gregstrq)\
**Replies:** 10\
**Last updated:** [January 26, 2018, 7:26pm UTC](https://discourse.julialang.org/t/slow-down-when-running-several-parallel-julia-processes-which-use-blas-mwe-is-provided/8400 "2018-01-26T19:26:43Z")

</div>

I observe a strange problem. I am doing Monte Carlo, so for now I start multiple julia processes from the bash, each of which gathers statistics. Running 4 processes in parallel I see a 4 times slow down in execution of…

---

## [Slow REPL after PyPlot](https://discourse.julialang.org/t/slow-repl-after-pyplot/7862)

<div class="topic-metadata">

**Author:** [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Replies:** 22\
**Last updated:** [January 24, 2018, 9:14am UTC](https://discourse.julialang.org/t/slow-repl-after-pyplot/7862 "2018-01-24T09:14:00Z")

</div>

I was using the REPL with 0.6.2 on MacOS, and noticed that if I create a plot with PyPlot, the REPL slows to a complete crawl, becoming unusable. This is after simple commands like: using PyPlot x = linspace(0,10)|\>col…

---

## [How to implement fast range reads for my custome-defined array?](https://discourse.julialang.org/t/how-to-implement-fast-range-reads-for-my-custome-defined-array/8490)

<div class="topic-metadata">

**Author:** [@jinliangwei](https://discourse.julialang.org/u/jinliangwei)\
**Replies:** 2\
**Last updated:** [January 20, 2018, 10:33pm UTC](https://discourse.julialang.org/t/how-to-implement-fast-range-reads-for-my-custome-defined-array/8490 "2018-01-20T22:33:29Z")

</div>

I need to implement my own array type underlying which is still a Vector, but reading/writing to it is much much slower than reading/writing the vanilla Julia array. I can reproduce the problem in this simple program bel…

---

## [PyCall: Weirdish PyArray conversion performance behaviour](https://discourse.julialang.org/t/pycall-weirdish-pyarray-conversion-performance-behaviour/8454)

<div class="topic-metadata">

**Author:** [@davidavdav](https://discourse.julialang.org/u/davidavdav)\
**Replies:** 2\
**Last updated:** [January 19, 2018, 2:48pm UTC](https://discourse.julialang.org/t/pycall-weirdish-pyarray-conversion-performance-behaviour/8454 "2018-01-19T14:48:21Z")

</div>

Hello, I have a PyCall-wrapped python module (musdb) that natively gives me PyArray{Float64}, which can be fairly large. At some stage I need an Array{Float32} of this, but conversion times vary a lot: @elapsed conver…

---

## [Localizing variables: performance implications?](https://discourse.julialang.org/t/localizing-variables-performance-implications/8329)

<div class="topic-metadata">

**Author:** [@SepandMeenu](https://discourse.julialang.org/u/SepandMeenu)\
**Replies:** 7\
**Last updated:** [January 18, 2018, 12:23pm UTC](https://discourse.julialang.org/t/localizing-variables-performance-implications/8329 "2018-01-18T12:23:15Z")

</div>

Is there any advantage to localizing variables in a Julia function? As an example, suppose that MyStruct is a mutable struct with a field x: mutable struct MyStruct x0 # ... end and a function which takes an…

---

## [Speeding up FVM code](https://discourse.julialang.org/t/speeding-up-fvm-code/8430)

<div class="topic-metadata">

**Author:** [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Replies:** 7\
**Last updated:** [January 17, 2018, 5:10pm UTC](https://discourse.julialang.org/t/speeding-up-fvm-code/8430 "2018-01-17T17:10:04Z")

</div>

Dear All, I have been trying to speed up the following piece of code for a FVM method. I used Threads in the first for-loop but it is slower. Ideally, I would like it to be parallel. So I am about to re-write it using s…

---

## [Reference or copy: segment of an array as function argument](https://discourse.julialang.org/t/reference-or-copy-segment-of-an-array-as-function-argument/8331)

<div class="topic-metadata">

**Author:** [@SepandMeenu](https://discourse.julialang.org/u/SepandMeenu)\
**Replies:** 9\
**Last updated:** [January 16, 2018, 9:32pm UTC](https://discourse.julialang.org/t/reference-or-copy-segment-of-an-array-as-function-argument/8331 "2018-01-16T21:32:32Z")

</div>

Sometimes, a segment of an array needs to be used as an argument to a function; e.g., consider searching for x in a part of an (sorted) array A: searchsortedfirst(A\[5:end\], x) Does this way produce a new copy of the co…

---

## [Fastest way to count unique elements in \`Vector{Union{Bool, Missing})\`](https://discourse.julialang.org/t/fastest-way-to-count-unique-elements-in-vector-union-bool-missing/8355)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 35\
**Last updated:** [January 16, 2018, 7:09pm UTC](https://discourse.julialang.org/t/fastest-way-to-count-unique-elements-in-vector-union-bool-missing/8355 "2018-01-16T19:09:08Z")

</div>

Given that missing is now in base I was testing ways to count unique element in a vector of boolean or missing. My code is below and I wonder if there is a faster way to achieve the count; I think not. I looked up the do…

---

## [Multi-threading doesn't seem to scale well on this counting problem](https://discourse.julialang.org/t/multi-threading-doesnt-seem-to-scale-well-on-this-counting-problem/8318)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 15\
**Last updated:** [January 14, 2018, 3:48am UTC](https://discourse.julialang.org/t/multi-threading-doesnt-seem-to-scale-well-on-this-counting-problem/8318 "2018-01-14T03:48:24Z")

</div>

I have been reading about multithreading and the general feel is that it’s very hard to get good performance out of it. After reading the post (https://github.com/JuliaLang/julia/issues/17395), I still feel hazy on what …

---

## [How to define an efficient \`bswap\_int\` for user defined primitive types?](https://discourse.julialang.org/t/how-to-define-an-efficient-bswap-int-for-user-defined-primitive-types/8051)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 8\
**Last updated:** [January 5, 2018, 7:05am UTC](https://discourse.julialang.org/t/how-to-define-an-efficient-bswap-int-for-user-defined-primitive-types/8051 "2018-01-05T07:05:48Z")

</div>

I am trying to define my own primitive type of bit-length 8\*n for some n, e.g. below I have n=3. The functions lshr\_int and shl\_int works directly on the newly-defined type but not bswap\_int. I tried to check its defini…

---

## [help understanding performance with assignment to allocated matrix](https://discourse.julialang.org/t/help-understanding-performance-with-assignment-to-allocated-matrix/8149)

<div class="topic-metadata">

**Author:** [@rmar](https://discourse.julialang.org/u/rmar)\
**Replies:** 6\
**Last updated:** [January 4, 2018, 8:03am UTC](https://discourse.julialang.org/t/help-understanding-performance-with-assignment-to-allocated-matrix/8149 "2018-01-04T08:03:26Z")

</div>

A pattern I often find useful is to assign to a slice of a matrix in a loop, forgoing the innermost loop, e.g.: for idat in 1:ndata array\[:, idat\] = \[xval, yval, zval\] end The vector of values assigned to the slice…

---

## [Sort huge array get smallest 1000](https://discourse.julialang.org/t/sort-huge-array-get-smallest-1000/8081)

<div class="topic-metadata">

**Author:** [@Wikunia](https://discourse.julialang.org/u/Wikunia)\
**Replies:** 5\
**Last updated:** [December 31, 2017, 5:00pm UTC](https://discourse.julialang.org/t/sort-huge-array-get-smallest-1000/8081 "2017-12-31T17:00:11Z")

</div>

Is there a function which sorts an array up to a given size? I know that quicksort divides the array into “halves” every time which should make it easy to get the smallest 1000 in an array of a million values. Does some…

---

## [Dispatch on argument values rather than (just) types?](https://discourse.julialang.org/t/dispatch-on-argument-values-rather-than-just-types/7974)

<div class="topic-metadata">

**Author:** [@sdwfrost](https://discourse.julialang.org/u/sdwfrost)\
**Replies:** 5\
**Last updated:** [December 26, 2017, 5:42am UTC](https://discourse.julialang.org/t/dispatch-on-argument-values-rather-than-just-types/7974 "2017-12-26T05:42:49Z")

</div>

Dear All, A rather broad question - I have cases where different algorithms are faster for different parameter values. I’d like to have a collection of different methods that are called according to some conditions. Ide…

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

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