# Performance

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

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

**Page:** 97

---

## [Why is plotting with GR faster when using GR\_jll and \`@ccall\` directly](https://discourse.julialang.org/t/why-is-plotting-with-gr-faster-when-using-gr-jll-and-ccall-directly/58199)

<div class="topic-metadata">

**Author:** [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Replies:** 9\
**Last updated:** [March 30, 2021, 6:57am UTC](https://discourse.julialang.org/t/why-is-plotting-with-gr-faster-when-using-gr-jll-and-ccall-directly/58199 "2021-03-30T06:57:01Z")

</div>

Why is plotting with GR faster when using GR\_jll and @ccall directly? @jheinen using GR\_jll \_ \_ \_(\_)\_ | Documentation: https://docs.julialang.org (\_) | (\_) (\_) | \_ \_ \_| |\_ \_\_ \_ | Type "?"…

---

## [Speed Up For Loop for Bounds Checking](https://discourse.julialang.org/t/speed-up-for-loop-for-bounds-checking/58188)

<div class="topic-metadata">

**Author:** [@PJoynt](https://discourse.julialang.org/u/PJoynt)\
**Replies:** 5\
**Last updated:** [March 29, 2021, 9:14pm UTC](https://discourse.julialang.org/t/speed-up-for-loop-for-bounds-checking/58188 "2021-03-29T21:14:31Z")

</div>

Hi, I was wondering if I could get some feedback on how I can increase the performance of this section of code, I am relatively new to Julia and I am not to sure if there is a better way to do this: x = \[-88.58, -86.31,…

---

## [Sqrt(abs(x)) is even faster than sqrt!](https://discourse.julialang.org/t/sqrt-abs-x-is-even-faster-than-sqrt/58154)

<div class="topic-metadata">

**Author:** [@Shuhua](https://discourse.julialang.org/u/Shuhua)\
**Replies:** 11\
**Last updated:** [March 29, 2021, 11:26am UTC](https://discourse.julialang.org/t/sqrt-abs-x-is-even-faster-than-sqrt/58154 "2021-03-29T11:26:09Z")

</div>

I accidentally found that computing both sqrt and abs is even faster than sqrt alone. julia\> using BenchmarkTools julia\> sqrt\_abs(x) = sqrt(abs(x)); julia\> const N = 1000; julia\> const positive\_x = randn(N) .^ 2 .+ 1…

---

## [Why is there memory allocation and time difference in @views and view?](https://discourse.julialang.org/t/why-is-there-memory-allocation-and-time-difference-in-views-and-view/58149)

<div class="topic-metadata">

**Author:** [@Shuhua](https://discourse.julialang.org/u/Shuhua)\
**Replies:** 9\
**Last updated:** [March 29, 2021, 8:07am UTC](https://discourse.julialang.org/t/why-is-there-memory-allocation-and-time-difference-in-views-and-view/58149 "2021-03-29T08:07:36Z")

</div>

Julia Version 1.5.3 julia\> f(a, b, c) = a + b - c; julia\> X = randn(1000, 5); julia\> y = zeros(1000); # feed the last three columns of \`X\` into \`f\` and write the result into \`y\` julia\> @btime $y .= f((view($X, :, j)…

---

## [Avoid allocation of small arrays in median, extrema, etc](https://discourse.julialang.org/t/avoid-allocation-of-small-arrays-in-median-extrema-etc/58075)

<div class="topic-metadata">

**Author:** [@weymouth](https://discourse.julialang.org/u/weymouth)\
**Replies:** 23\
**Last updated:** [March 28, 2021, 9:45pm UTC](https://discourse.julialang.org/t/avoid-allocation-of-small-arrays-in-median-extrema-etc/58075 "2021-03-28T21:45:48Z")

</div>

I have a performance critical call to set bounds on a number. This code works like magic, but I want to know why it doesn’t need to allocate julia\> @benchmark clamp(v\[1\],extrema((v\[2\],v\[3\],v\[4\]))...) setup=(v=rand(4)) B…

---

## [Performance of norm function](https://discourse.julialang.org/t/performance-of-norm-function/14709)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 21\
**Last updated:** [March 28, 2021, 1:15pm UTC](https://discourse.julialang.org/t/performance-of-norm-function/14709 "2021-03-28T13:15:49Z")

</div>

Custom for-loop seems 3x faster than LinearAlgebra’s norm… julia\> using LinearAlgebra, BenchmarkTools julia\> A = rand(5,5); julia\> function foo1(A) x = zero(eltype(A)) for v in A x += v \*…

---

## [Performance regression with SAs as parameters in DiffEqs on Julia 1.6](https://discourse.julialang.org/t/performance-regression-with-sas-as-parameters-in-diffeqs-on-julia-1-6/58103)

<div class="topic-metadata">

**Author:** [@dcabecinhas](https://discourse.julialang.org/u/dcabecinhas)\
**Replies:** 0\
**Last updated:** [March 28, 2021, 1:32am UTC](https://discourse.julialang.org/t/performance-regression-with-sas-as-parameters-in-diffeqs-on-julia-1-6/58103 "2021-03-28T01:32:33Z")

</div>

Hi all, I have some code where I pass parameters to ODE problems and it had some performance regressions with Julia 1.6. I distilled the code to highlight what seems to me to be at the root of the problem - passing Sta…

---

## [ControlSystems -- transfer functions with delay?](https://discourse.julialang.org/t/controlsystems-transfer-functions-with-delay/58003)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 12\
**Last updated:** [March 27, 2021, 9:24pm UTC](https://discourse.julialang.org/t/controlsystems-transfer-functions-with-delay/58003 "2021-03-27T21:24:24Z")

</div>

From the documentation: ControlSystems.tf — Function. sys = tf(num, den, Ts=0), sys = tf(gain, Ts=0) → Is it possible to define a time delay for functions tf and zpk? I’m trying to “sell” Julia to a friend, and he…

---

## [Which is the most efficient way to add matrices/arrays in Julia 1.x?](https://discourse.julialang.org/t/which-is-the-most-efficient-way-to-add-matrices-arrays-in-julia-1-x/39602)

<div class="topic-metadata">

**Author:** [@KZiemian](https://discourse.julialang.org/u/KZiemian)\
**Replies:** 11\
**Last updated:** [March 26, 2021, 8:17pm UTC](https://discourse.julialang.org/t/which-is-the-most-efficient-way-to-add-matrices-arrays-in-julia-1-x/39602 "2021-03-26T20:17:58Z")

</div>

Adding matrices is very important thing in numerical computations and I fell that discusion of results of benchmarking this in Julia 1.x should take place here. Because I don’t find such topic on Julia Discourse I put wh…

---

## [Optimizing semiclassical simulation for a lattice system](https://discourse.julialang.org/t/optimizing-semiclassical-simulation-for-a-lattice-system/58014)

<div class="topic-metadata">

**Author:** [@Joh11](https://discourse.julialang.org/u/Joh11)\
**Replies:** 7\
**Last updated:** [March 26, 2021, 4:55pm UTC](https://discourse.julialang.org/t/optimizing-semiclassical-simulation-for-a-lattice-system/58014 "2021-03-26T16:55:13Z")

</div>

Hi everyone, I am currently working on implementing an implementation of semiclassical Monte Carlo for a lattice system (https://github.com/Joh11/semiclassical-monte-carlo). I would like to make my code faster. The bot…

---

## [Nsight compute from CUDA.jl and source annotation](https://discourse.julialang.org/t/nsight-compute-from-cuda-jl-and-source-annotation/57855)

<div class="topic-metadata">

**Author:** [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Replies:** 3\
**Last updated:** [March 25, 2021, 7:28am UTC](https://discourse.julialang.org/t/nsight-compute-from-cuda-jl-and-source-annotation/57855 "2021-03-25T07:28:48Z")

</div>

Hi, I try to build a training session on GPU programming (including kernel programming) and I want to use Julia and CUDA.jl as a development environment. Profiling is an essential tool for GPGPU and I think that profili…

---

## [Manual dispatch over a constant type set](https://discourse.julialang.org/t/manual-dispatch-over-a-constant-type-set/57811)

<div class="topic-metadata">

**Author:** [@RGon](https://discourse.julialang.org/u/RGon)\
**Replies:** 5\
**Last updated:** [March 24, 2021, 10:01pm UTC](https://discourse.julialang.org/t/manual-dispatch-over-a-constant-type-set/57811 "2021-03-24T22:01:09Z")

</div>

I’m trying to run a simulation that has many different thermodynamic methods depending on the substance type (usually phase), and it’s nice to be able to easily choose what method to use. Long story short, I need to be a…

---

## [Tutorial: How to benchmark and profile your code?](https://discourse.julialang.org/t/tutorial-how-to-benchmark-and-profile-your-code/57790)

<div class="topic-metadata">

**Author:** [@Wikunia](https://discourse.julialang.org/u/Wikunia)\
**Replies:** 11\
**Last updated:** [March 24, 2021, 7:20am UTC](https://discourse.julialang.org/t/tutorial-how-to-benchmark-and-profile-your-code/57790 "2021-03-24T07:20:46Z")

</div>

Interested in benchmarking and profiling your code? My new blog post walks you through it from highlevel benchmarking to getting deeper with profiling tools. It’s quite high level so I avoided explaining the different …

---

## [Completely frustrated with compilation times](https://discourse.julialang.org/t/completely-frustrated-with-compilation-times/57733)

<div class="topic-metadata">

**Author:** [@andreasvarga](https://discourse.julialang.org/u/andreasvarga)\
**Replies:** 16\
**Last updated:** [March 23, 2021, 7:03pm UTC](https://discourse.julialang.org/t/completely-frustrated-with-compilation-times/57733 "2021-03-23T19:03:25Z")

</div>

I am working with Julia 1.5.3 on the development of a new package DescriptorSystems, which basically manipulates 5-tuples of matrices (which describe so called descriptor systems). Recently, I added a new object, which i…

---

## [Shuffle values and sample indices of a sparse matrix](https://discourse.julialang.org/t/shuffle-values-and-sample-indices-of-a-sparse-matrix/57677)

<div class="topic-metadata">

**Author:** [@eliassno](https://discourse.julialang.org/u/eliassno)\
**Replies:** 15\
**Last updated:** [March 23, 2021, 5:50pm UTC](https://discourse.julialang.org/t/shuffle-values-and-sample-indices-of-a-sparse-matrix/57677 "2021-03-23T17:50:24Z")

</div>

I need to shuffle entries in selected columns of a large, sparse matrix X with dimensions M x N . I have written a function that does this in-place, as I need to perform the shuffling repeatedly on the same data. functi…

---

## [Count words challenge](https://discourse.julialang.org/t/count-words-challenge/57221)

<div class="topic-metadata">

**Author:** [@alemelis](https://discourse.julialang.org/u/alemelis)\
**Replies:** 24\
**Last updated:** [March 23, 2021, 2:10pm UTC](https://discourse.julialang.org/t/count-words-challenge/57221 "2021-03-23T14:10:06Z")

</div>

Hello! I’ve been reading this blog post today and decided to give it a try in Julia. In short, the idea is to benchmark different languages in counting words frequency for long text files. I’ve added what I believe is…

---

## [Experiments with VectorizationBase](https://discourse.julialang.org/t/experiments-with-vectorizationbase/57475)

<div class="topic-metadata">

**Author:** [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Replies:** 6\
**Last updated:** [March 23, 2021, 3:17am UTC](https://discourse.julialang.org/t/experiments-with-vectorizationbase/57475 "2021-03-23T03:17:12Z")

</div>

I’ve been trying out VectorizationBase for some low-level SIMD coding. This has worked but I suspect there may be better ways to go about it or at least I need some pointers for how to adapt to some recent changes in thi…

---

## [Using anonymous Functions to avoid type dispatch](https://discourse.julialang.org/t/using-anonymous-functions-to-avoid-type-dispatch/57749)

<div class="topic-metadata">

**Author:** [@nben](https://discourse.julialang.org/u/nben)\
**Replies:** 0\
**Last updated:** [March 22, 2021, 8:52pm UTC](https://discourse.julialang.org/t/using-anonymous-functions-to-avoid-type-dispatch/57749 "2021-03-22T20:52:10Z")

</div>

This question is about the merits of a methods of avoiding type dispatch in some low-level functions. I’ve included the context below; though the question itself can probably be understood and answered without the contex…

---

## [Optimizing an ODEProblem with Threads?](https://discourse.julialang.org/t/optimizing-an-odeproblem-with-threads/57732)

<div class="topic-metadata">

**Author:** [@cmarcotte](https://discourse.julialang.org/u/cmarcotte)\
**Replies:** 1\
**Last updated:** [March 22, 2021, 4:14pm UTC](https://discourse.julialang.org/t/optimizing-an-odeproblem-with-threads/57732 "2021-03-22T16:14:58Z")

</div>

I have a sizable (402) ODE system which comes from the discretization of a parabolic PDE (Beeler-Reuter model in 1D); in the past I used ModelingToolkit to optimize my poorly written in-place function by evaluating it ov…

---

## [Xticks in month format](https://discourse.julialang.org/t/xticks-in-month-format/57721)

<div class="topic-metadata">

**Author:** [@dires](https://discourse.julialang.org/u/dires)\
**Replies:** 2\
**Last updated:** [March 22, 2021, 3:51pm UTC](https://discourse.julialang.org/t/xticks-in-month-format/57721 "2021-03-22T15:51:39Z")

</div>

Hi I am working on a yearly planning model in hourly resolution, and I want to plot the result with the X-axis in months, not in hours. how can I do my plots in Gadfly?

---

## [Expectation of multidimensional value function with discrete states](https://discourse.julialang.org/t/expectation-of-multidimensional-value-function-with-discrete-states/57570)

<div class="topic-metadata">

**Author:** [@dadada\_dadada](https://discourse.julialang.org/u/dadada_dadada)\
**Replies:** 18\
**Last updated:** [March 22, 2021, 1:43pm UTC](https://discourse.julialang.org/t/expectation-of-multidimensional-value-function-with-discrete-states/57570 "2021-03-22T13:43:44Z")

</div>

Hello, I have a dynamic programming problem in which I need to calculate the conditional expectation of the next period value function of my problem. The expectation is conditional on my current states and action, and …

---

## [Accelerating computations Neural Network](https://discourse.julialang.org/t/accelerating-computations-neural-network/57670)

<div class="topic-metadata">

**Author:** [@moby75](https://discourse.julialang.org/u/moby75)\
**Replies:** 6\
**Last updated:** [March 22, 2021, 7:30am UTC](https://discourse.julialang.org/t/accelerating-computations-neural-network/57670 "2021-03-22T07:30:02Z")

</div>

I am new to Julia and to Cuda programming. I am using Julia 1.0.5. I wrote a code to do neural network inferences: it consists on a series of multiplications (neural network weights\* Input/layers) and adding Biases. I …

---

## [How to attach to an existing remote REPL?](https://discourse.julialang.org/t/how-to-attach-to-an-existing-remote-repl/27608)

<div class="topic-metadata">

**Author:** [@csavorgn](https://discourse.julialang.org/u/csavorgn)\
**Replies:** 23\
**Last updated:** [March 22, 2021, 5:01am UTC](https://discourse.julialang.org/t/how-to-attach-to-an-existing-remote-repl/27608 "2021-03-22T05:01:07Z")

</div>

Hi, In my workflow I need to run several simulations which make use of the DifferentialEquations package. To automate running the simulations I need to start the simulations from command line (and not within the Julia …

---

## [Julia reporting an extra ) when it doesn't exist](https://discourse.julialang.org/t/julia-reporting-an-extra-when-it-doesnt-exist/57644)

<div class="topic-metadata">

**Author:** [@oo92](https://discourse.julialang.org/u/oo92)\
**Replies:** 6\
**Last updated:** [March 21, 2021, 8:50am UTC](https://discourse.julialang.org/t/julia-reporting-an-extra-when-it-doesnt-exist/57644 "2021-03-21T08:50:05Z")

</div>

I have this for loop in Julia: for country in countries\_data\_labels new\_dataframe = get\_country(df, country) new\_dataframe = DataFrame(new\_dataframe) df\_rows, df\_columns = size(new\_dataframe)…

---

## [Julia for real time, worried about the garbage collector](https://discourse.julialang.org/t/julia-for-real-time-worried-about-the-garbage-collector/34654)

<div class="topic-metadata">

**Author:** [@gosim](https://discourse.julialang.org/u/gosim)\
**Replies:** 48\
**Last updated:** [March 21, 2021, 1:16am UTC](https://discourse.julialang.org/t/julia-for-real-time-worried-about-the-garbage-collector/34654 "2021-03-21T01:16:35Z")

</div>

Hello, totally new. I’ve read about Julia and the concept seems great. I have a block diagram software (like simulink) that automatically creates a script, works well and it is using m-code where every block is a functi…

---

## [Algorithmic complexity of matrix multiplication in Julia](https://discourse.julialang.org/t/algorithmic-complexity-of-matrix-multiplication-in-julia/57468)

<div class="topic-metadata">

**Author:** [@IlliaFaraji](https://discourse.julialang.org/u/IlliaFaraji)\
**Replies:** 10\
**Last updated:** [March 20, 2021, 12:57pm UTC](https://discourse.julialang.org/t/algorithmic-complexity-of-matrix-multiplication-in-julia/57468 "2021-03-20T12:57:09Z")

</div>

This is a slightly odd question, but I am working on a project for which I would like to know the algorithmic complexity of matrix multiplication in Julia. i.e. if A, B are two dimensional n x n arrays stored in the usua…

---

## [Need help understanding performance hit of Arrays](https://discourse.julialang.org/t/need-help-understanding-performance-hit-of-arrays/57450)

<div class="topic-metadata">

**Author:** [@nandoconde](https://discourse.julialang.org/u/nandoconde)\
**Replies:** 3\
**Last updated:** [March 20, 2021, 10:03am UTC](https://discourse.julialang.org/t/need-help-understanding-performance-hit-of-arrays/57450 "2021-03-20T10:03:03Z")

</div>

Intro Hello! I have been using Julia regularly for some months and I am starting to have a good mental map of the way Julia works internally, meaning, which operations can be optimized by the compiler and how to write le…

---

## [Discrete event simulation framework for discrete time](https://discourse.julialang.org/t/discrete-event-simulation-framework-for-discrete-time/55436)

<div class="topic-metadata">

**Author:** [@manuka](https://discourse.julialang.org/u/manuka)\
**Replies:** 4\
**Last updated:** [March 19, 2021, 8:56am UTC](https://discourse.julialang.org/t/discrete-event-simulation-framework-for-discrete-time/55436 "2021-03-19T08:56:57Z")

</div>

I would like to receive feedback on my simulation model. I have posted it in codereview.stackexchange but recieved almost no feedback (Discrete event simulation framework for discrete times in Julia - Code Review Stack E…

---

## [Garbage collector, C malloc and performance](https://discourse.julialang.org/t/garbage-collector-c-malloc-and-performance/57320)

<div class="topic-metadata">

**Author:** [@KZiemian](https://discourse.julialang.org/u/KZiemian)\
**Replies:** 2\
**Last updated:** [March 19, 2021, 5:40am UTC](https://discourse.julialang.org/t/garbage-collector-c-malloc-and-performance/57320 "2021-03-19T05:40:50Z")

</div>

I recently read very old blog post by Joel Spolsky Back to Basics from 2002 (side effect of reading about floating-point numbers, you know how this work). He stated that C code that use malloc can suffer for problems ver…

---

## [How to propagate @inbounds properly](https://discourse.julialang.org/t/how-to-propagate-inbounds-properly/57487)

<div class="topic-metadata">

**Author:** [@Uroc327](https://discourse.julialang.org/u/Uroc327)\
**Replies:** 8\
**Last updated:** [March 18, 2021, 8:47pm UTC](https://discourse.julialang.org/t/how-to-propagate-inbounds-properly/57487 "2021-03-18T20:47:08Z")

</div>

I have a bunch of more or less complex functions that have arrays and indices as arguments. I’d like to specify @inbounds once at the top-level function and propagate this down through all nested and standalone functions…

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

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