# Performance

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

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

**Page:** 112

---

## [Can I set @optlevel as a user per module or per function?](https://discourse.julialang.org/t/can-i-set-optlevel-as-a-user-per-module-or-per-function/44192)

<div class="topic-metadata">

**Author:** [@klaff](https://discourse.julialang.org/u/klaff)\
**Replies:** 10\
**Last updated:** [August 5, 2020, 12:27pm UTC](https://discourse.julialang.org/t/can-i-set-optlevel-as-a-user-per-module-or-per-function/44192 "2020-08-05T12:27:11Z")

</div>

Specifically, I’m playing with rapidly updating plots in a Pluto environment and would like to increase the level of optimizations applied to Plots.jl as a user to see if it changes update rates.

---

## [Compare permutaion of two numbers efficiently?](https://discourse.julialang.org/t/compare-permutaion-of-two-numbers-efficiently/44195)

<div class="topic-metadata">

**Author:** [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Replies:** 32\
**Last updated:** [August 4, 2020, 9:12am UTC](https://discourse.julialang.org/t/compare-permutaion-of-two-numbers-efficiently/44195 "2020-08-04T09:12:20Z")

</div>

I’m trying to compare two numbers to check if they have identical digits but in different orders. I extracted the digits and sorted them, then I compare the two extracted vectors to check equality. This works fine, but I…

---

## [\[solved\] Agents.jl spending 3/4 of its time doing something before it even starts to compute?](https://discourse.julialang.org/t/solved-agents-jl-spending-3-4-of-its-time-doing-something-before-it-even-starts-to-compute/44109)

<div class="topic-metadata">

**Author:** [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Replies:** 11\
**Last updated:** [August 3, 2020, 3:58pm UTC](https://discourse.julialang.org/t/solved-agents-jl-spending-3-4-of-its-time-doing-something-before-it-even-starts-to-compute/44109 "2020-08-03T15:58:41Z")

</div>

I’m running a simulation with 10000 agents in a continuous space. Even 4 time steps takes minutes… Netlogo can do a similar thing in milliseconds. So of course I hit the profiler: 131╎131 @Base/dict.jl:279; ht\_key…

---

## [Avoid allocations](https://discourse.julialang.org/t/avoid-allocations/44187)

<div class="topic-metadata">

**Author:** [@nhavt](https://discourse.julialang.org/u/nhavt)\
**Replies:** 3\
**Last updated:** [August 3, 2020, 1:44pm UTC](https://discourse.julialang.org/t/avoid-allocations/44187 "2020-08-03T13:44:40Z")

</div>

Hi there, suppose that I have a Float64 vector x. I wish to identify non-zero elements of this vector. Below are my proposal for that. f1!(y,x) = y .= (x .!=0 )\[:\]; function f2!(y,x) @inbounds @simd for i ∈ eachinde…

---

## [Can this code be made faster](https://discourse.julialang.org/t/can-this-code-be-made-faster/44122)

<div class="topic-metadata">

**Author:** [@Sanji\_Vinsmoke](https://discourse.julialang.org/u/Sanji_Vinsmoke)\
**Replies:** 9\
**Last updated:** [August 2, 2020, 4:58pm UTC](https://discourse.julialang.org/t/can-this-code-be-made-faster/44122 "2020-08-02T16:58:45Z")

</div>

I attempted the Advent od Code 2015 day 9 solution in julia and here is my code for the first part (for this input 9.txt file refer to the link to the problem): using Combinatorics, BenchmarkTools distances = readlines…

---

## [\`issubset(::BitSet,::BitSet)\` is slow and allocates unnecessarily](https://discourse.julialang.org/t/issubset-bitset-bitset-is-slow-and-allocates-unnecessarily/43828)

<div class="topic-metadata">

**Author:** [@guyvdb](https://discourse.julialang.org/u/guyvdb)\
**Replies:** 1\
**Last updated:** [August 2, 2020, 1:28pm UTC](https://discourse.julialang.org/t/issubset-bitset-bitset-is-slow-and-allocates-unnecessarily/43828 "2020-08-02T13:28:10Z")

</div>

The implementation of issubset between two BitSet: https://github.com/JuliaLang/julia/blob/3909294e78d223c740b7e7a4d00eb2d4771055a7/base/bitset.jl#L419 first intersects the sets. This unnecessarily allocates memory to c…

---

## [Alternatives to pipelining Table operations like "filter" and "columns"? How to speed this up?](https://discourse.julialang.org/t/alternatives-to-pipelining-table-operations-like-filter-and-columns-how-to-speed-this-up/44100)

<div class="topic-metadata">

**Author:** [@kai](https://discourse.julialang.org/u/kai)\
**Replies:** 3\
**Last updated:** [August 2, 2020, 6:04am UTC](https://discourse.julialang.org/t/alternatives-to-pipelining-table-operations-like-filter-and-columns-how-to-speed-this-up/44100 "2020-08-02T06:04:33Z")

</div>

Hi all, I found that the following chunk is the major bottleneck in my code. For each “id” (subject), it uses pipelines to filter out the data for that “id”, creates the columns object, and then build the MyObs type. I…

---

## [\`TypeVar\` or \`eltype\`, which is faster?](https://discourse.julialang.org/t/typevar-or-eltype-which-is-faster/44113)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 1\
**Last updated:** [August 1, 2020, 11:50pm UTC](https://discourse.julialang.org/t/typevar-or-eltype-which-is-faster/44113 "2020-08-01T23:50:52Z")

</div>

Consider the following code using Unitful function f(arr::AbstractArray{T}) where {T} N = length(arr) return NTuple{N,T}(arr) end or function g(arr::AbstractArray) N, T = length(arr), eltype(arr) retu…

---

## [Trying to speed-up Laplace Equation Solver](https://discourse.julialang.org/t/trying-to-speed-up-laplace-equation-solver/43862)

<div class="topic-metadata">

**Author:** [@SambitMishra98](https://discourse.julialang.org/u/SambitMishra98)\
**Replies:** 36\
**Last updated:** [August 1, 2020, 10:14pm UTC](https://discourse.julialang.org/t/trying-to-speed-up-laplace-equation-solver/43862 "2020-08-01T22:14:26Z")

</div>

I am trying to speedup my code for Laplace Equation Solver. Based on code profiling, most of the time goes in the function given below. I have tried to optimise the functions as much as possible but the performance still…

---

## [Speed improvement possible?](https://discourse.julialang.org/t/speed-improvement-possible/44065)

<div class="topic-metadata">

**Author:** [@Ruan\_Stander](https://discourse.julialang.org/u/Ruan_Stander)\
**Replies:** 1\
**Last updated:** [August 1, 2020, 6:46am UTC](https://discourse.julialang.org/t/speed-improvement-possible/44065 "2020-08-01T06:46:14Z")

</div>

Would appreciate tips to improve speed of code below. Transforms a dataset into an input matrix and corresponding output whilst skipping missing output values function AddMatrixToInput!(row,day,instrument,Imatrix,pcMatr…

---

## [Efficient parsing of arrays of arrays of arrays or arbitrary number of arrays of arrays?](https://discourse.julialang.org/t/efficient-parsing-of-arrays-of-arrays-of-arrays-or-arbitrary-number-of-arrays-of-arrays/43972)

<div class="topic-metadata">

**Author:** [@Marcell\_Havlik](https://discourse.julialang.org/u/Marcell_Havlik)\
**Replies:** 7\
**Last updated:** [July 31, 2020, 11:56am UTC](https://discourse.julialang.org/t/efficient-parsing-of-arrays-of-arrays-of-arrays-or-arbitrary-number-of-arrays-of-arrays/43972 "2020-07-31T11:56:04Z")

</div>

Hey Julianers, I parsed a JSON file with JSON2.jl and now I have to postprocess the results it into an Array{Array{Float32, N},1}. The problem is that, the JSON parsed struct is an arrays of arrays of arrays of … and so…

---

## [At a glance, why don't I have better performances between Julia and PHP?](https://discourse.julialang.org/t/at-a-glance-why-dont-i-have-better-performances-between-julia-and-php/43804)

<div class="topic-metadata">

**Author:** [@Darione](https://discourse.julialang.org/u/Darione)\
**Replies:** 24\
**Last updated:** [July 30, 2020, 5:41pm UTC](https://discourse.julialang.org/t/at-a-glance-why-dont-i-have-better-performances-between-julia-and-php/43804 "2020-07-30T17:41:16Z")

</div>

Hi everyone! I manage an automatic warehouse, where there are trays with a certain number of items inside. I was trying to do a count with Julia, elaborating some csv files that I export from my management and that repr…

---

## [Why is my @animate loop super slow?](https://discourse.julialang.org/t/why-is-my-animate-loop-super-slow/43685)

<div class="topic-metadata">

**Author:** [@aramirezreyes](https://discourse.julialang.org/u/aramirezreyes)\
**Replies:** 9\
**Last updated:** [July 30, 2020, 6:30pm UTC](https://discourse.julialang.org/t/why-is-my-animate-loop-super-slow/43685 "2020-07-30T18:30:40Z")

</div>

Hi! I’m trying to understand why is the using the Plots.jl @animate macro slower than plotting and saving many times. I destilled my real case into this hopefully MWE. I have a function that creates a plot with several…

---

## [Matrix-vector multiplication slower than a 'naive' for loop?](https://discourse.julialang.org/t/matrix-vector-multiplication-slower-than-a-naive-for-loop/43910)

<div class="topic-metadata">

**Author:** [@barankarakus](https://discourse.julialang.org/u/barankarakus)\
**Replies:** 7\
**Last updated:** [July 30, 2020, 8:29am UTC](https://discourse.julialang.org/t/matrix-vector-multiplication-slower-than-a-naive-for-loop/43910 "2020-07-30T08:29:20Z")

</div>

Hi, I’m new to Julia and have been playing around with it to test its performance claims. I am looking to multiply a matrix X by a sparse vector β, generated via the following code: n = 500 p = 100000 β = rand(p); z…

---

## [Why is functor slower than eval'ed function?](https://discourse.julialang.org/t/why-is-functor-slower-than-evaled-function/43840)

<div class="topic-metadata">

**Author:** [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Replies:** 8\
**Last updated:** [July 29, 2020, 2:48pm UTC](https://discourse.julialang.org/t/why-is-functor-slower-than-evaled-function/43840 "2020-07-29T14:48:25Z")

</div>

I have a situation where I’d like to build some functions based on different inputs - using a callable function seems really clear to me, and has the functionality I want. I’d rather not use eval and other metaprogrammin…

---

## [Problem with the calling of Laplacian.jl functions from PyJulia](https://discourse.julialang.org/t/problem-with-the-calling-of-laplacian-jl-functions-from-pyjulia/43829)

<div class="topic-metadata">

**Author:** [@Alip](https://discourse.julialang.org/u/Alip)\
**Replies:** 0\
**Last updated:** [July 28, 2020, 6:26pm UTC](https://discourse.julialang.org/t/problem-with-the-calling-of-laplacian-jl-functions-from-pyjulia/43829 "2020-07-28T18:26:13Z")

</div>

I’m trying to call some functions from the laplacians.jl package by using PyJulia in my python code. It seems that I cannot run the code from Pyjulia because when I use the function directly in the Julia environment it w…

---

## [Read csv files slow](https://discourse.julialang.org/t/read-csv-files-slow/43803)

<div class="topic-metadata">

**Author:** [@Ruan\_Stander](https://discourse.julialang.org/u/Ruan_Stander)\
**Replies:** 13\
**Last updated:** [July 28, 2020, 6:29pm UTC](https://discourse.julialang.org/t/read-csv-files-slow/43803 "2020-07-28T18:29:28Z")

</div>

Hi I am loading a long list of text files into memory using DataFrames (joined on the Date Column) It is taking very long to read them in so tried to do multithreading since my nthreads()=12 The multithreading is only…

---

## [Best performance for eval of expressions with parameters](https://discourse.julialang.org/t/best-performance-for-eval-of-expressions-with-parameters/43443)

<div class="topic-metadata">

**Author:** [@oheil](https://discourse.julialang.org/u/oheil)\
**Replies:** 2\
**Last updated:** [July 28, 2020, 2:07pm UTC](https://discourse.julialang.org/t/best-performance-for-eval-of-expressions-with-parameters/43443 "2020-07-28T14:07:40Z")

</div>

I try to achieve better/best performance for eval(expression). Up to now I found 5 more or less different possibilities (in respect to my code logic) to eval an expression. It’s best, to see it in code. The following MW…

---

## [Read multiple csv files](https://discourse.julialang.org/t/read-multiple-csv-files/43806)

<div class="topic-metadata">

**Author:** [@Ruan\_Stander](https://discourse.julialang.org/u/Ruan_Stander)\
**Replies:** 1\
**Last updated:** [July 28, 2020, 9:33am UTC](https://discourse.julialang.org/t/read-multiple-csv-files/43806 "2020-07-28T09:33:35Z")

</div>

How should I approach reading multiple files in one CSV.File call ? fileDirectory="d:/Data/Test/" using Glob files=glob("\*.txt", fileDirectory) df3=DataFrame(CSV.File(files)) MethodError: no method matching joinpath(:…

---

## [Can Julia really be used as a scripting language? (Performance)](https://discourse.julialang.org/t/can-julia-really-be-used-as-a-scripting-language-performance/40384)

<div class="topic-metadata">

**Author:** [@singpolyma](https://discourse.julialang.org/u/singpolyma)\
**Replies:** 69\
**Last updated:** [July 28, 2020, 6:50am UTC](https://discourse.julialang.org/t/can-julia-really-be-used-as-a-scripting-language-performance/40384 "2020-07-28T06:50:48Z")

</div>

I’ve been reading the docs, and getting pretty excited about Julia’s potential as a replacement for Ruby in my workflows, however I very quickly seem to have run into a brick wall once trying to actually use it: it’s inc…

---

## [How to make faster in a matrix multiplication inside a loop?](https://discourse.julialang.org/t/how-to-make-faster-in-a-matrix-multiplication-inside-a-loop/43783)

<div class="topic-metadata">

**Author:** [@jmcastro2109](https://discourse.julialang.org/u/jmcastro2109)\
**Replies:** 2\
**Last updated:** [July 27, 2020, 6:48pm UTC](https://discourse.julialang.org/t/how-to-make-faster-in-a-matrix-multiplication-inside-a-loop/43783 "2020-07-27T18:48:19Z")

</div>

Hi! Is there a way to implement the following function faster? Seeds = rand(200,90,15000,10) Mat = rand(200,200) @views function testfunction(Seeds,Mat) (J,T,N,S) = size(Seeds) ν = zeros(Float32,J,T,N,S)…

---

## [Matrix computation](https://discourse.julialang.org/t/matrix-computation/42835)

<div class="topic-metadata">

**Author:** [@nhavt](https://discourse.julialang.org/u/nhavt)\
**Replies:** 6\
**Last updated:** [July 27, 2020, 4:36pm UTC](https://discourse.julialang.org/t/matrix-computation/42835 "2020-07-27T16:36:27Z")

</div>

Hello all, I have the following function that I would need to optimize. This is because this function is called multiple times (at least 500). So, it is crucial to optimize this function. The computing time with my comp…

---

## [Gradient through categorical distribution slow and has many allocations](https://discourse.julialang.org/t/gradient-through-categorical-distribution-slow-and-has-many-allocations/43690)

<div class="topic-metadata">

**Author:** [@scottjordan](https://discourse.julialang.org/u/scottjordan)\
**Replies:** 0\
**Last updated:** [July 26, 2020, 1:21am UTC](https://discourse.julialang.org/t/gradient-through-categorical-distribution-slow-and-has-many-allocations/43690 "2020-07-26T01:21:18Z")

</div>

I am trying have performant gradients computations for a function the defines a conditional distribution over a discrete space. More specifically, I want the gradient of the following function: import Flux import Zygote…

---

## [One-pass NaN variance](https://discourse.julialang.org/t/one-pass-nan-variance/43622)

<div class="topic-metadata">

**Author:** [@Benjia](https://discourse.julialang.org/u/Benjia)\
**Replies:** 3\
**Last updated:** [July 25, 2020, 4:36am UTC](https://discourse.julialang.org/t/one-pass-nan-variance/43622 "2020-07-25T04:36:37Z")

</div>

I’d like to try and use the implementation of Welford’s algorithm in Base.Statistics, but filter out NaNs along the way. First thing I tried is the following: Statistics.var(Iterators.filter(!isnan, vals)) However, th…

---

## [Is there a way to reinterpret a Float64 to 2 Int32?](https://discourse.julialang.org/t/is-there-a-way-to-reinterpret-a-float64-to-2-int32/43596)

<div class="topic-metadata">

**Author:** [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Replies:** 3\
**Last updated:** [July 24, 2020, 11:24pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-reinterpret-a-float64-to-2-int32/43596 "2020-07-24T23:24:46Z")

</div>

I’m writing some manually vectorize some code (for computing exp), and I was looking for a way to view the memory as 2 int32s (if it helps, I only need the lower one). Is there a way to do this? The reason I want Int32 r…

---

## [Memory allocation in broadcast assignment](https://discourse.julialang.org/t/memory-allocation-in-broadcast-assignment/43613)

<div class="topic-metadata">

**Author:** [@serenity4](https://discourse.julialang.org/u/serenity4)\
**Replies:** 3\
**Last updated:** [July 24, 2020, 8:05pm UTC](https://discourse.julialang.org/t/memory-allocation-in-broadcast-assignment/43613 "2020-07-24T20:05:33Z")

</div>

Hi! I am struggling to keep a certain level of flexibility and abstraction while optimizing for performance. For example, in the following function, I am doing some processing and modify an array arr in-place. arr = zer…

---

## [How to achieve the greatest speed with nested loops?](https://discourse.julialang.org/t/how-to-achieve-the-greatest-speed-with-nested-loops/43578)

<div class="topic-metadata">

**Author:** [@Joris\_Pinkse](https://discourse.julialang.org/u/Joris_Pinkse)\
**Replies:** 10\
**Last updated:** [July 24, 2020, 2:47pm UTC](https://discourse.julialang.org/t/how-to-achieve-the-greatest-speed-with-nested-loops/43578 "2020-07-24T14:47:20Z")

</div>

I have a large three-dimensional array X and wish to compute the sum over i of X\[i,j,m\] \* X\[i,t,m\] producing a three-dimensional array Y. I’ve tried the following (my arrays will be larger than this). using BenchmarkT…

---

## [String pool / indirect array analogue to make a struct isbits?](https://discourse.julialang.org/t/string-pool-indirect-array-analogue-to-make-a-struct-isbits/43503)

<div class="topic-metadata">

**Author:** [@evanfields](https://discourse.julialang.org/u/evanfields)\
**Replies:** 5\
**Last updated:** [July 23, 2020, 10:09pm UTC](https://discourse.julialang.org/t/string-pool-indirect-array-analogue-to-make-a-struct-isbits/43503 "2020-07-23T22:09:30Z")

</div>

I have a program which ingests JSON describe a list of objects. For the sake of example, let’s say each object is a Cartesian point with a name: struct NamedPoint x::Float64 y::Float64 name::String end The …

---

## [Regime estimation for parameter space of small system](https://discourse.julialang.org/t/regime-estimation-for-parameter-space-of-small-system/41588)

<div class="topic-metadata">

**Author:** [@SidxA](https://discourse.julialang.org/u/SidxA)\
**Replies:** 7\
**Last updated:** [July 22, 2020, 4:14pm UTC](https://discourse.julialang.org/t/regime-estimation-for-parameter-space-of-small-system/41588 "2020-07-22T16:14:02Z")

</div>

Hello julia community, I’m relatively new to julia and have a few questions regarding a dynamical system representing a simple ecological model of five coupled equations. The goal is to let the system integrate for so…

---

## [Branch elimination in Julia](https://discourse.julialang.org/t/branch-elimination-in-julia/43471)

<div class="topic-metadata">

**Author:** [@ettersi](https://discourse.julialang.org/u/ettersi)\
**Replies:** 7\
**Last updated:** [July 22, 2020, 12:18pm UTC](https://discourse.julialang.org/t/branch-elimination-in-julia/43471 "2020-07-22T12:18:43Z")

</div>

I have always been fascinated by the effect of branch prediction demonstrated in this StackOverflow question, and I wanted to include this example in my course to illustrate how hard it is to predict the performance of m…

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

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