# Performance

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

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

**Page:** 99

---

## [How to improve include() performance in runtests.jl?](https://discourse.julialang.org/t/how-to-improve-include-performance-in-runtests-jl/56987)

<div class="topic-metadata">

**Author:** [@bdoolittle](https://discourse.julialang.org/u/bdoolittle)\
**Replies:** 2\
**Last updated:** [March 12, 2021, 1:39am UTC](https://discourse.julialang.org/t/how-to-improve-include-performance-in-runtests-jl/56987 "2021-03-12T01:39:14Z")

</div>

Hello, Julia users. I’ve recently noticed that when I run the unit tests of my module, a significant amount of time appears to be spent on include statements like include("test/path/to/file.jl") where the included files …

---

## [Discussion on Base.@pure usage](https://discourse.julialang.org/t/discussion-on-base-pure-usage/56491)

<div class="topic-metadata">

**Author:** [@rryi](https://discourse.julialang.org/u/rryi)\
**Replies:** 23\
**Last updated:** [March 12, 2021, 12:10am UTC](https://discourse.julialang.org/t/discussion-on-base-pure-usage/56491 "2021-03-12T00:10:19Z")

</div>

\[edit 21/03/07 discussion in this thread is about correct @pure use, triggered by the @pure annotation in my initial question about NamedTuple type processing “with zero runtime costs”, which follows\] I have a custom Ba…

---

## [External product of StaticArrays vectors](https://discourse.julialang.org/t/external-product-of-staticarrays-vectors/56955)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Replies:** 2\
**Last updated:** [March 11, 2021, 3:38pm UTC](https://discourse.julialang.org/t/external-product-of-staticarrays-vectors/56955 "2021-03-11T15:38:39Z")

</div>

Hi, I have two SVector’s, and I wish to compute their external product. I have three requirements the output should be a SMatrix, the operation should be FAST (slow, I can do myself…) preferably, the output is non-mu…

---

## [Possible bug in KrylovKit.eigsolve](https://discourse.julialang.org/t/possible-bug-in-krylovkit-eigsolve/55962)

<div class="topic-metadata">

**Author:** [@iamsuddhasattwa](https://discourse.julialang.org/u/iamsuddhasattwa)\
**Replies:** 11\
**Last updated:** [March 10, 2021, 8:36pm UTC](https://discourse.julialang.org/t/possible-bug-in-krylovkit-eigsolve/55962 "2021-03-10T20:36:06Z")

</div>

I am trying to find the first 4 eigenvalues of a symmetric 8X8 matrix, arranged in increasing order of real part. Symmetry means that the eigenvalues are real. Moreover, as you will see from the output, it is a block dia…

---

## [How to force compile-time evaluation of literal calculations?](https://discourse.julialang.org/t/how-to-force-compile-time-evaluation-of-literal-calculations/56822)

<div class="topic-metadata">

**Author:** [@robsmith11](https://discourse.julialang.org/u/robsmith11)\
**Replies:** 4\
**Last updated:** [March 9, 2021, 5:18pm UTC](https://discourse.julialang.org/t/how-to-force-compile-time-evaluation-of-literal-calculations/56822 "2021-03-09T17:18:16Z")

</div>

I often want to write large integer values such as 10^6 in performance critical functions. I would expect Julia to perform these calculations at compile-time when possible, but it doesn’t appear to do so: julia\> functi…

---

## [How to resolve \`Any\`s in this function?](https://discourse.julialang.org/t/how-to-resolve-any-s-in-this-function/56717)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 16\
**Last updated:** [March 9, 2021, 12:44pm UTC](https://discourse.julialang.org/t/how-to-resolve-any-s-in-this-function/56717 "2021-03-09T12:44:07Z")

</div>

Consider this: using ComponentArrays, Parameters function test(g, a; data=data) @unpack P = data if g == 1 oc = (g, a) -\> P\[g, a\] elseif g == 2 oc = (g, a) -\> P\[g, a\] + 1 end return…

---

## [General questions from Python user](https://discourse.julialang.org/t/general-questions-from-python-user/55475)

<div class="topic-metadata">

**Author:** [@lancejnelson](https://discourse.julialang.org/u/lancejnelson)\
**Replies:** 59\
**Last updated:** [March 8, 2021, 10:49pm UTC](https://discourse.julialang.org/t/general-questions-from-python-user/55475 "2021-03-08T22:49:39Z")

</div>

Hi all, I heard from a friend that this is a great place to have conversations about Julia. I’ve been using Python for years but am intrigued by Julia. Big picture question: Will I have to try really hard to get Jul…

---

## [Modifiying Julia tuple, Dict and object from C](https://discourse.julialang.org/t/modifiying-julia-tuple-dict-and-object-from-c/56469)

<div class="topic-metadata">

**Author:** [@Clonkk](https://discourse.julialang.org/u/Clonkk)\
**Replies:** 9\
**Last updated:** [March 8, 2021, 8:47am UTC](https://discourse.julialang.org/t/modifiying-julia-tuple-dict-and-object-from-c/56469 "2021-03-08T08:47:43Z")

</div>

Hello, I haven’t seen anything in the documentation so I’m asking here; is there a way to manipulate tuple, Dict and object from C ? I create the Julia type in C using jl\_eval function - I haven’t found another way to …

---

## [Why does wrapping an array in a composite type degrade performance?](https://discourse.julialang.org/t/why-does-wrapping-an-array-in-a-composite-type-degrade-performance/56197)

<div class="topic-metadata">

**Author:** [@mroavi](https://discourse.julialang.org/u/mroavi)\
**Replies:** 3\
**Last updated:** [March 4, 2021, 9:49am UTC](https://discourse.julialang.org/t/why-does-wrapping-an-array-in-a-composite-type-degrade-performance/56197 "2021-03-04T09:49:55Z")

</div>

The code below performs 2 broadcast multiplications between 2 3D-arrays. The result of the latter is wrapped in a composite type. Does anybody know why the former is faster and allocates less memory? Is it a benchmarking…

---

## [Interprete Profile results](https://discourse.julialang.org/t/interprete-profile-results/55902)

<div class="topic-metadata">

**Author:** [@Lian\_Yunlong](https://discourse.julialang.org/u/Lian_Yunlong)\
**Replies:** 6\
**Last updated:** [March 4, 2021, 8:52am UTC](https://discourse.julialang.org/t/interprete-profile-results/55902 "2021-03-04T08:52:52Z")

</div>

Dear Julia experts, I have profiled my code and get the following results. The major worker in the code is a recursive function. Does this result show that something is wrong with that ? Perhaps I should specify the inp…

---

## [Python vs. Julia ODE Solver](https://discourse.julialang.org/t/python-vs-julia-ode-solver/56123)

<div class="topic-metadata">

**Author:** [@qtoloza](https://discourse.julialang.org/u/qtoloza)\
**Replies:** 30\
**Last updated:** [March 3, 2021, 5:59pm UTC](https://discourse.julialang.org/t/python-vs-julia-ode-solver/56123 "2021-03-03T17:59:45Z")

</div>

Hello! Brand new to Julia. I have a very stiff system of ODEs that I’m trying to optimize for large N. I’ve achieved reasonable performance in Python using SciPy+Numba, but I wanted to see if Julia would be superior. So …

---

## [Threads, @spawn on Mac - inconsistent behavior](https://discourse.julialang.org/t/threads-spawn-on-mac-inconsistent-behavior/56376)

<div class="topic-metadata">

**Author:** [@marsmen](https://discourse.julialang.org/u/marsmen)\
**Replies:** 1\
**Last updated:** [March 3, 2021, 7:54am UTC](https://discourse.julialang.org/t/threads-spawn-on-mac-inconsistent-behavior/56376 "2021-03-03T07:54:17Z")

</div>

I’ve a school project to conduct FFTs with Julia. I need to show that running a 1D FFT on an image is faster when running in parallel on the processor’s cores then when running a single instance. I think the reality is, …

---

## [Map vs Loops & Array Comprehensions in Julia 1.0](https://discourse.julialang.org/t/map-vs-loops-array-comprehensions-in-julia-1-0/16137)

<div class="topic-metadata">

**Author:** [@mdsalerno](https://discourse.julialang.org/u/mdsalerno)\
**Replies:** 10\
**Last updated:** [March 3, 2021, 7:41am UTC](https://discourse.julialang.org/t/map-vs-loops-array-comprehensions-in-julia-1-0/16137 "2021-03-03T07:41:49Z")

</div>

I’ve seen some older threads on this topic, but is it still the case that loops and array comprehensions are significantly faster than map() in Julia 1.0? If so, can someone provide intuition into why this is the case. …

---

## [Multithreading an embarrassingly parallel algorithm increases garbage collection](https://discourse.julialang.org/t/multithreading-an-embarrassingly-parallel-algorithm-increases-garbage-collection/56261)

<div class="topic-metadata">

**Author:** [@andrekal](https://discourse.julialang.org/u/andrekal)\
**Replies:** 12\
**Last updated:** [March 1, 2021, 8:04pm UTC](https://discourse.julialang.org/t/multithreading-an-embarrassingly-parallel-algorithm-increases-garbage-collection/56261 "2021-03-01T20:04:14Z")

</div>

Hi, Hope this MWE is clear enough. I’m trying to implement a certain algorithm in which I fill out a matrix (about 5000x6000) with known dimensions column by column. The calculation of each column is completely indepen…

---

## [Inverse transform sampling (discrete distributions sampling)?](https://discourse.julialang.org/t/inverse-transform-sampling-discrete-distributions-sampling/56255)

<div class="topic-metadata">

**Author:** [@riegel\_gestr](https://discourse.julialang.org/u/riegel_gestr)\
**Replies:** 4\
**Last updated:** [March 1, 2021, 6:29pm UTC](https://discourse.julialang.org/t/inverse-transform-sampling-discrete-distributions-sampling/56255 "2021-03-01T18:29:49Z")

</div>

I am currently working on inverse transform sampling: Inverse transform sampling - Wikipedia, also here http://dept.stat.lsa.umich.edu/~jasoneg/Stat406/lab5.pdf I have implemented the following version of the algo: us…

---

## [In place sorting for views](https://discourse.julialang.org/t/in-place-sorting-for-views/56194)

<div class="topic-metadata">

**Author:** [@Skoffer](https://discourse.julialang.org/u/Skoffer)\
**Replies:** 12\
**Last updated:** [March 1, 2021, 11:55am UTC](https://discourse.julialang.org/t/in-place-sorting-for-views/56194 "2021-03-01T11:55:21Z")

</div>

Maybe I am benchmarking it wrong, but it seems that sorting part of the vector (with the help of @views) is slower than sorting original vector. using BenchmarkTools v = rand(1000); v2 = rand(2000); v2\[500:1499\] .= v;…

---

## [Parallelizing interpolation? (BoundsError)](https://discourse.julialang.org/t/parallelizing-interpolation-boundserror/56221)

<div class="topic-metadata">

**Author:** [@taeukseo](https://discourse.julialang.org/u/taeukseo)\
**Replies:** 2\
**Last updated:** [March 1, 2021, 5:18am UTC](https://discourse.julialang.org/t/parallelizing-interpolation-boundserror/56221 "2021-03-01T05:18:31Z")

</div>

Hi, I am new to Julia and I have been trying to use Interpolations.jl to obtain interpolated values for grids. At some point, the number of points became quite large and I felt I should try to parallelize the code but ha…

---

## [Why findall() function is super slow?](https://discourse.julialang.org/t/why-findall-function-is-super-slow/56222)

<div class="topic-metadata">

**Author:** [@Nova](https://discourse.julialang.org/u/Nova)\
**Replies:** 5\
**Last updated:** [March 1, 2021, 3:55am UTC](https://discourse.julialang.org/t/why-findall-function-is-super-slow/56222 "2021-03-01T03:55:11Z")

</div>

Here is an example and I’m just wondering why it takes 51 mS to do this considering the input size is very small. aa = \[1,2,3,4,5,6\] bb = \[2,5\] @time findall(x-\>x==bb, aa) julia\> @time findall(x-\>in(x, bb), aa) 0.051…

---

## [Is there documentation on how to use MKL with libblastrampoline](https://discourse.julialang.org/t/is-there-documentation-on-how-to-use-mkl-with-libblastrampoline/56108)

<div class="topic-metadata">

**Author:** [@dmbates](https://discourse.julialang.org/u/dmbates)\
**Replies:** 2\
**Last updated:** [February 28, 2021, 8:48am UTC](https://discourse.julialang.org/t/is-there-documentation-on-how-to-use-mkl-with-libblastrampoline/56108 "2021-02-28T08:48:37Z")

</div>

Now that https://github.com/JuliaLang/julia/pull/39455 has been merged, is there documentation on how to use MKL blas via libblastrampoline?

---

## [Optimize function with complex square root](https://discourse.julialang.org/t/optimize-function-with-complex-square-root/56058)

<div class="topic-metadata">

**Author:** [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Replies:** 12\
**Last updated:** [February 27, 2021, 5:24pm UTC](https://discourse.julialang.org/t/optimize-function-with-complex-square-root/56058 "2021-02-27T17:24:32Z")

</div>

Hello, I am writing a routine to store a matrix that contains the values of f(x, z) = \\frac{1}{\\sqrt{1-x^2}} \\times \\text{real}\\left(\\frac{\\sqrt{z-1}\\sqrt{z+1}}{z-x}\\right) for \\sim 1000 real values x \\in \[-1, 1\] and \\…

---

## [So does Julia compile or interpret?](https://discourse.julialang.org/t/so-does-julia-compile-or-interpret/56073)

<div class="topic-metadata">

**Author:** [@xyz1](https://discourse.julialang.org/u/xyz1)\
**Replies:** 1\
**Last updated:** [February 26, 2021, 10:57am UTC](https://discourse.julialang.org/t/so-does-julia-compile-or-interpret/56073 "2021-02-26T10:57:35Z")

</div>

Hi, I’ve been searching for this but I’m not sure there is a definitive answer written somewhere. I understand it may be an “implementation detail” and that “julia compiles to efficient native code for multiple platforms…

---

## [Most efficient way of calculating a multidimensional complex function many times](https://discourse.julialang.org/t/most-efficient-way-of-calculating-a-multidimensional-complex-function-many-times/55943)

<div class="topic-metadata">

**Author:** [@O\_Julia](https://discourse.julialang.org/u/O_Julia)\
**Replies:** 7\
**Last updated:** [February 25, 2021, 8:56pm UTC](https://discourse.julialang.org/t/most-efficient-way-of-calculating-a-multidimensional-complex-function-many-times/55943 "2021-02-25T20:56:26Z")

</div>

I have a very long function depends on X,Y,T. X and Y are vectors with length between 400-10000. I have to calculate the function in a for loop many times. Are my approachs efficient? If not, how can I improve them? Than…

---

## [Force calling the generic for benchmarking](https://discourse.julialang.org/t/force-calling-the-generic-for-benchmarking/56009)

<div class="topic-metadata">

**Author:** [@lrnv](https://discourse.julialang.org/u/lrnv)\
**Replies:** 1\
**Last updated:** [February 25, 2021, 12:08pm UTC](https://discourse.julialang.org/t/force-calling-the-generic-for-benchmarking/56009 "2021-02-25T12:08:36Z")

</div>

Consider the following dummy example: function f(x) println("We called the generic") prod(x) end function f(x::Real) println("We called the method") x end # Some checks: f(1) f(\[1 2\]) How can I force f…

---

## [Annotation to elide function call if the return value is unused](https://discourse.julialang.org/t/annotation-to-elide-function-call-if-the-return-value-is-unused/55904)

<div class="topic-metadata">

**Author:** [@goretkin](https://discourse.julialang.org/u/goretkin)\
**Replies:** 5\
**Last updated:** [February 24, 2021, 11:52pm UTC](https://discourse.julialang.org/t/annotation-to-elide-function-call-if-the-return-value-is-unused/55904 "2021-02-24T23:52:26Z")

</div>

Is there some annotation that I can use to give permission to the compiler to elide e.g. x = foo(y) if x is not used? And would it possibly work across function-call boundaries? I’d like to do something like function fo…

---

## [Why specify argument types and return types](https://discourse.julialang.org/t/why-specify-argument-types-and-return-types/55567)

<div class="topic-metadata">

**Author:** [@lancejnelson](https://discourse.julialang.org/u/lancejnelson)\
**Replies:** 38\
**Last updated:** [February 24, 2021, 11:51pm UTC](https://discourse.julialang.org/t/why-specify-argument-types-and-return-types/55567 "2021-02-24T23:51:44Z")

</div>

New Julia user here. Trying to understand the benefit of this: function test(p::Float64,x::Int) :: Float64 \<do something\> end over the more pythonic: function test(p,x) \<do something\> end The same question could…

---

## [On the performance of function calls that depends on a variable](https://discourse.julialang.org/t/on-the-performance-of-function-calls-that-depends-on-a-variable/55573)

<div class="topic-metadata">

**Author:** [@moudbis](https://discourse.julialang.org/u/moudbis)\
**Replies:** 12\
**Last updated:** [February 24, 2021, 2:07pm UTC](https://discourse.julialang.org/t/on-the-performance-of-function-calls-that-depends-on-a-variable/55573 "2021-02-24T14:07:39Z")

</div>

Hello everyone, Sorry, it’s going to be a bit long. I’m trying to reach performance in Julia for function calls that depends on a variable. It means given a line in my code, I can’t tell which function will be run in a…

---

## [Status of "let" statements before Threads.@threads](https://discourse.julialang.org/t/status-of-let-statements-before-threads-threads/55813)

<div class="topic-metadata">

**Author:** [@swishmas](https://discourse.julialang.org/u/swishmas)\
**Replies:** 4\
**Last updated:** [February 23, 2021, 6:33pm UTC](https://discourse.julialang.org/t/status-of-let-statements-before-threads-threads/55813 "2021-02-23T18:33:10Z")

</div>

Hello! I found myself using a lot of let statements before multi-threaded for-loops with the Threads.@threads command in my code. I wanted to know if these were still useful in the present version of julia now. Does an…

---

## [Fast hamming distance function in Julia that returns a distance matrix](https://discourse.julialang.org/t/fast-hamming-distance-function-in-julia-that-returns-a-distance-matrix/55716)

<div class="topic-metadata">

**Author:** [@giac](https://discourse.julialang.org/u/giac)\
**Replies:** 12\
**Last updated:** [February 21, 2021, 6:20pm UTC](https://discourse.julialang.org/t/fast-hamming-distance-function-in-julia-that-returns-a-distance-matrix/55716 "2021-02-21T18:20:28Z")

</div>

I am trying to compute the hamming distance on a very large dataset. I need to get back a distance matrix between rows in order to run further analysis on this matrix. For my purposes, it is useful that the data are sto…

---

## [Evaluate Piecewise Functions Effciently](https://discourse.julialang.org/t/evaluate-piecewise-functions-effciently/55832)

<div class="topic-metadata">

**Author:** [@drarnau](https://discourse.julialang.org/u/drarnau)\
**Replies:** 3\
**Last updated:** [February 23, 2021, 11:54am UTC](https://discourse.julialang.org/t/evaluate-piecewise-functions-effciently/55832 "2021-02-23T11:54:46Z")

</div>

Dear all, I have a very basic (maybe stupid) question. I need to evaluate a piecewise function many times. My naive approach is to do something like: function myPiecewise(a,b) if a \< 0 return 0.5\*a + b else …

---

## [Conversion of properties of a NamedTuple or struct](https://discourse.julialang.org/t/conversion-of-properties-of-a-namedtuple-or-struct/55769)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Replies:** 2\
**Last updated:** [February 23, 2021, 5:43am UTC](https://discourse.julialang.org/t/conversion-of-properties-of-a-namedtuple-or-struct/55769 "2021-02-23T05:43:41Z")

</div>

I want write a piece of code that will receive large arrays of “state variables” from finite element codes, and do a conversion on all the e.g. Float64 appearing in this data structure. There are many element types, I d…

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

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