# Performance

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

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

**Page:** 114

---

## [Comparing matrix multiplication between Julia and C](https://discourse.julialang.org/t/comparing-matrix-multiplication-between-julia-and-c/42692)

<div class="topic-metadata">

**Author:** [@saulo.giovani](https://discourse.julialang.org/u/saulo.giovani)\
**Replies:** 2\
**Last updated:** [July 7, 2020, 10:38pm UTC](https://discourse.julialang.org/t/comparing-matrix-multiplication-between-julia-and-c/42692 "2020-07-07T22:38:52Z")

</div>

Hey, community! I was comparing matrix multiplication performance using loops in C and Julia and I would like to know if someone could help me with one doubt about Matrix Acess behavior. I have read in the text “What Eve…

---

## [Performance of views vs. explicit index referencing](https://discourse.julialang.org/t/performance-of-views-vs-explicit-index-referencing/42644)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 2\
**Last updated:** [July 7, 2020, 12:07am UTC](https://discourse.julialang.org/t/performance-of-views-vs-explicit-index-referencing/42644 "2020-07-07T00:07:57Z")

</div>

I spent some time trying to understand the advantages and disadvantages of using views in my code. The main reason for using views, in my case, was simplifying the code, by (as one example), having only one method to com…

---

## [Should I use @inbounds on for loop iterating through the values of a Dict?](https://discourse.julialang.org/t/should-i-use-inbounds-on-for-loop-iterating-through-the-values-of-a-dict/42570)

<div class="topic-metadata">

**Author:** [@jchen975](https://discourse.julialang.org/u/jchen975)\
**Replies:** 3\
**Last updated:** [July 6, 2020, 6:03am UTC](https://discourse.julialang.org/t/should-i-use-inbounds-on-for-loop-iterating-through-the-values-of-a-dict/42570 "2020-07-06T06:03:26Z")

</div>

Hello, I’m wondering if it’s appropriate (and necessary) to use @inbounds on a for loop that iterates through the keys/values of a Dict. After a quick search the examples where @inbounds helps are where I’m indexing an A…

---

## [Broadcast into higher dimensional array vs nested array](https://discourse.julialang.org/t/broadcast-into-higher-dimensional-array-vs-nested-array/42454)

<div class="topic-metadata">

**Author:** [@kschurter](https://discourse.julialang.org/u/kschurter)\
**Replies:** 4\
**Last updated:** [July 3, 2020, 10:26pm UTC](https://discourse.julialang.org/t/broadcast-into-higher-dimensional-array-vs-nested-array/42454 "2020-07-03T22:26:48Z")

</div>

I want to broadcast a vector-valued function and store the results in a higher dimensional array as opposed to a vector of arrays. I like the performance of this code: import .Base: Broadcast import .Broadcast: Broadcas…

---

## [Using module variables in a module function. Is there a performance disadvantage?](https://discourse.julialang.org/t/using-module-variables-in-a-module-function-is-there-a-performance-disadvantage/42465)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 4\
**Last updated:** [July 3, 2020, 12:56pm UTC](https://discourse.julialang.org/t/using-module-variables-in-a-module-function-is-there-a-performance-disadvantage/42465 "2020-07-03T12:56:30Z")

</div>

module A b = "test" function crazy\_use\_of\_b\_1() #... using A.b end function crazy\_use\_of\_b\_2(;\_b = A.b) #... using \_b end end Is there a performance difference from 1 to 2. Or problems with type stabilit…

---

## [Efficient (non-allocating, in-place) getindex! for BitArray?](https://discourse.julialang.org/t/efficient-non-allocating-in-place-getindex-for-bitarray/42268)

<div class="topic-metadata">

**Author:** [@JeffFessler](https://discourse.julialang.org/u/JeffFessler)\
**Replies:** 19\
**Last updated:** [July 2, 2020, 1:30pm UTC](https://discourse.julialang.org/t/efficient-non-allocating-in-place-getindex-for-bitarray/42268 "2020-07-02T13:30:26Z")

</div>

I have an indexing operation of the form y .= x\[mask\] where mask is a BitArray. To my surprise, this is an allocating operation even though it could be done in place in compiled code. So I wrote a loop that is non-allo…

---

## [Undefined Variable](https://discourse.julialang.org/t/undefined-variable/42416)

<div class="topic-metadata">

**Author:** [@hyacykcharel](https://discourse.julialang.org/u/hyacykcharel)\
**Replies:** 1\
**Last updated:** [July 2, 2020, 8:25am UTC](https://discourse.julialang.org/t/undefined-variable/42416 "2020-07-02T08:25:06Z")

</div>

function Plot\_Poisson\_Equation(n) A = zeros(n-1,n-1) for i in 1:n-2 A\[i,i+1\] = -1 A\[i,i\] = 2 A\[i+1,i\] = -1 end end Hello Im still gettin Erro A, and u not define…

---

## [Parallel workflow](https://discourse.julialang.org/t/parallel-workflow/42259)

<div class="topic-metadata">

**Author:** [@grahamas](https://discourse.julialang.org/u/grahamas)\
**Replies:** 2\
**Last updated:** [July 1, 2020, 3:05pm UTC](https://discourse.julialang.org/t/parallel-workflow/42259 "2020-07-01T15:05:38Z")

</div>

I’m running a bunch of DiffEq solvers in parallel, summarizing the results, and then saving them. Can anyone recommend the best workflow to do this given the current state of Julia’s parallel code, either v1.4 or v1.5? …

---

## [Fast iteration over rows of a DataFrame](https://discourse.julialang.org/t/fast-iteration-over-rows-of-a-dataframe/24612)

<div class="topic-metadata">

**Author:** [@robsmith11](https://discourse.julialang.org/u/robsmith11)\
**Replies:** 14\
**Last updated:** [June 30, 2020, 3:20pm UTC](https://discourse.julialang.org/t/fast-iteration-over-rows-of-a-dataframe/24612 "2020-06-30T15:20:56Z")

</div>

I want to read a CSV file and do some path-dependent calculations involving multiple columns (i.e., no vectorization allowed in the actual problem.) I was surprised to see that in a simple example, DataFrames introduce …

---

## [Why does this allocate?](https://discourse.julialang.org/t/why-does-this-allocate/42298)

<div class="topic-metadata">

**Author:** [@cafaxo](https://discourse.julialang.org/u/cafaxo)\
**Replies:** 4\
**Last updated:** [June 30, 2020, 12:23pm UTC](https://discourse.julialang.org/t/why-does-this-allocate/42298 "2020-06-30T12:23:42Z")

</div>

Consider the following code: function foo(x) if x\[1\] \> 0 (x, 1) else nothing end end It seems that this code has 1 allocation: julia\> bla = \[1\] 1-element Array{Int64,1}: 1 julia\> @time f…

---

## [Comparing Julia Performance to CLI Program](https://discourse.julialang.org/t/comparing-julia-performance-to-cli-program/42280)

<div class="topic-metadata">

**Author:** [@mtsch](https://discourse.julialang.org/u/mtsch)\
**Replies:** 0\
**Last updated:** [June 30, 2020, 2:22am UTC](https://discourse.julialang.org/t/comparing-julia-performance-to-cli-program/42280 "2020-06-30T02:22:01Z")

</div>

Hi, I have written a Julia package that is based on an algorithm that is used by a CLI program. I’m trying to perform some benchmarks to see where I stand. I want to eventually publish the results, so I want to make sur…

---

## [Another post on package compilation time](https://discourse.julialang.org/t/another-post-on-package-compilation-time/42015)

<div class="topic-metadata">

**Author:** [@Albert\_Zevelev](https://discourse.julialang.org/u/Albert_Zevelev)\
**Replies:** 14\
**Last updated:** [June 29, 2020, 2:27pm UTC](https://discourse.julialang.org/t/another-post-on-package-compilation-time/42015 "2020-06-29T14:27:40Z")

</div>

Let me start by saying I’m very new to issues regarding compilation. (I never heard of compilation when I used Matlab-R-STATA.) Suppose I load a Julia package AAA.jl with one function f(x,y) . The first time I call f(…

---

## [Are let blocks as fast as functions?](https://discourse.julialang.org/t/are-let-blocks-as-fast-as-functions/42115)

<div class="topic-metadata">

**Author:** [@jfan](https://discourse.julialang.org/u/jfan)\
**Replies:** 11\
**Last updated:** [June 29, 2020, 2:27pm UTC](https://discourse.julialang.org/t/are-let-blocks-as-fast-as-functions/42115 "2020-06-29T14:27:33Z")

</div>

Based on reading this discussion and having to write a large script (I prefer script files), I find that using functions for “for loops” is a pain in my application. Since the matrices I’m dealing with are very large (~ …

---

## [Non-allocating views](https://discourse.julialang.org/t/non-allocating-views/42249)

<div class="topic-metadata">

**Author:** [@codebilly](https://discourse.julialang.org/u/codebilly)\
**Replies:** 2\
**Last updated:** [June 29, 2020, 1:36pm UTC](https://discourse.julialang.org/t/non-allocating-views/42249 "2020-06-29T13:36:47Z")

</div>

I recently installed Julia Version 1.5.0-beta1.0 and I was impressed with the non-allocating views. I just tried an example of LU factorisation written in vectorised style to get a feel for it, and the performance compa…

---

## [Why DataFrames v.0.21.2 (julia v1.4.2) requires more memory than the previous version](https://discourse.julialang.org/t/why-dataframes-v-0-21-2-julia-v1-4-2-requires-more-memory-than-the-previous-version/41171)

<div class="topic-metadata">

**Author:** [@BMval](https://discourse.julialang.org/u/BMval)\
**Replies:** 22\
**Last updated:** [June 29, 2020, 2:45am UTC](https://discourse.julialang.org/t/why-dataframes-v-0-21-2-julia-v1-4-2-requires-more-memory-than-the-previous-version/41171 "2020-06-29T02:45:50Z")

</div>

I’ve updated to DataFrame v.0.21.2 and Julia ver 1.4.2. Try to load CSV file (9GB), as result 32 GB Ram is not enough. Is it reasonable? Why DataFrames consume so much memory?

---

## [Help improving a function that constructs 3D matrix](https://discourse.julialang.org/t/help-improving-a-function-that-constructs-3d-matrix/42208)

<div class="topic-metadata">

**Author:** [@ycrichard](https://discourse.julialang.org/u/ycrichard)\
**Replies:** 3\
**Last updated:** [June 28, 2020, 11:24pm UTC](https://discourse.julialang.org/t/help-improving-a-function-that-constructs-3d-matrix/42208 "2020-06-28T23:24:48Z")

</div>

Hi Everyone! I am recently porting some functions from Matlab to Julia. Julia is mostly amazing except this function that I cannot get it to a similar speed as Matlab. It basically takes a few input vectors and constru…

---

## [Julia (with compile time) about 5.6 times faster than SAS](https://discourse.julialang.org/t/julia-with-compile-time-about-5-6-times-faster-than-sas/42159)

<div class="topic-metadata">

**Author:** [@ajsagit](https://discourse.julialang.org/u/ajsagit)\
**Replies:** 23\
**Last updated:** [June 28, 2020, 6:57pm UTC](https://discourse.julialang.org/t/julia-with-compile-time-about-5-6-times-faster-than-sas/42159 "2020-06-28T18:57:11Z")

</div>

\[Original title: Julia benchmark against SAS only 50% We need a faster Julia please\] I have read the article :BENCHMARKING JULIA AGAINST PYTHON https://juliacomputing.com/assets/pdf/JuliaVsPython.pdf So Amazing! Then …

---

## [Memory allocation within loop](https://discourse.julialang.org/t/memory-allocation-within-loop/23999)

<div class="topic-metadata">

**Author:** [@drarnau](https://discourse.julialang.org/u/drarnau)\
**Replies:** 7\
**Last updated:** [June 28, 2020, 2:17am UTC](https://discourse.julialang.org/t/memory-allocation-within-loop/23999 "2020-06-28T02:17:32Z")

</div>

I have a for loop in which I create a function that I optimize, something like: using Interpolations, Optim function PolicyFunction() V = Array{Float64}(undef, 201, 40) n = Array{Float64}(undef, 201, 40) gr…

---

## [Compiler optimizations with broadcast or map](https://discourse.julialang.org/t/compiler-optimizations-with-broadcast-or-map/42119)

<div class="topic-metadata">

**Author:** [@kschurter](https://discourse.julialang.org/u/kschurter)\
**Replies:** 5\
**Last updated:** [June 27, 2020, 10:11pm UTC](https://discourse.julialang.org/t/compiler-optimizations-with-broadcast-or-map/42119 "2020-06-27T22:11:34Z")

</div>

I come to Julia from R and have never thought much about compilation or compiler optimizations. As far as I am aware, a simple optimization that a compiler can implement is to take an operation outside of a loop, e.g. d…

---

## [Extra allocation when trying to reuse pre-allocated vector](https://discourse.julialang.org/t/extra-allocation-when-trying-to-reuse-pre-allocated-vector/42112)

<div class="topic-metadata">

**Author:** [@v-i-s-h](https://discourse.julialang.org/u/v-i-s-h)\
**Replies:** 6\
**Last updated:** [June 27, 2020, 9:13am UTC](https://discourse.julialang.org/t/extra-allocation-when-trying-to-reuse-pre-allocated-vector/42112 "2020-06-27T09:13:45Z")

</div>

Hi, I am trying to generate data for logistic regression y (which is {0, 1}) from X and β. I already allocate the space for y and then wrote function to computing the same in two different ways. I then use TimerOutputs…

---

## [Memory allocation and performance](https://discourse.julialang.org/t/memory-allocation-and-performance/42110)

<div class="topic-metadata">

**Author:** [@Joao\_Barata](https://discourse.julialang.org/u/Joao_Barata)\
**Replies:** 7\
**Last updated:** [June 26, 2020, 5:56pm UTC](https://discourse.julialang.org/t/memory-allocation-and-performance/42110 "2020-06-26T17:56:39Z")

</div>

Hi guys, I’m using Julia to compute a dynamic programming model. There is one particular part of the model that takes a long time to run (about 15 seconds, which is a lot, given that there is an iterative procedure invo…

---

## [A question about PCA and visualization](https://discourse.julialang.org/t/a-question-about-pca-and-visualization/42111)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 1\
**Last updated:** [June 26, 2020, 3:04pm UTC](https://discourse.julialang.org/t/a-question-about-pca-and-visualization/42111 "2020-06-26T15:04:46Z")

</div>

How do I draw a scatter plot using the projection matrix obtained from PCA? thanks!!

---

## [Poor performance of \`lock(l) do\` closures, caused by poor performance of capturing closures](https://discourse.julialang.org/t/poor-performance-of-lock-l-do-closures-caused-by-poor-performance-of-capturing-closures/42067)

<div class="topic-metadata">

**Author:** [@NHDaly](https://discourse.julialang.org/u/NHDaly)\
**Replies:** 11\
**Last updated:** [June 26, 2020, 2:45am UTC](https://discourse.julialang.org/t/poor-performance-of-lock-l-do-closures-caused-by-poor-performance-of-capturing-closures/42067 "2020-06-26T02:45:38Z")

</div>

Multithreading is hard. Correctly and safely locking and unlocking can be hard. For these reasons, we prefer abstractions that help us do things safely and correctly. One such abstraction is the lock() method that take…

---

## [What is the fastest way to update a particular row of a matrix using dot syntax?](https://discourse.julialang.org/t/what-is-the-fastest-way-to-update-a-particular-row-of-a-matrix-using-dot-syntax/36160)

<div class="topic-metadata">

**Author:** [@tomohiro\_soejima](https://discourse.julialang.org/u/tomohiro_soejima)\
**Replies:** 21\
**Last updated:** [June 25, 2020, 7:58pm UTC](https://discourse.julialang.org/t/what-is-the-fastest-way-to-update-a-particular-row-of-a-matrix-using-dot-syntax/36160 "2020-06-25T19:58:17Z")

</div>

Hi, I have a square matrix M, and I would like to update it in-place such that the kth column is multiplied by some scalar s. I’ve tried implementing it with dot syntax and simple rolling out of the for loop. function …

---

## [Parrallel programming2](https://discourse.julialang.org/t/parrallel-programming2/42027)

<div class="topic-metadata">

**Author:** [@hyacykcharel](https://discourse.julialang.org/u/hyacykcharel)\
**Replies:** 3\
**Last updated:** [June 25, 2020, 10:46am UTC](https://discourse.julialang.org/t/parrallel-programming2/42027 "2020-06-25T10:46:40Z")

</div>

Hello im trying to run this for loop parallel on evwery Process but still getting Error ,I Triyed it in 2 ways, can someone Help please?thanks using Distributed addprocs(2) @everywhere using DistributedArrays @every…

---

## [Speeding up repeated optimizations within a large loop](https://discourse.julialang.org/t/speeding-up-repeated-optimizations-within-a-large-loop/41901)

<div class="topic-metadata">

**Author:** [@asyadav](https://discourse.julialang.org/u/asyadav)\
**Replies:** 7\
**Last updated:** [June 25, 2020, 7:22am UTC](https://discourse.julialang.org/t/speeding-up-repeated-optimizations-within-a-large-loop/41901 "2020-06-25T07:22:59Z")

</div>

Hi there! I’m trying to solve an economic model with many discrete and continuous choices and a fairly large state space. My approach essentially boils down to solving several constrained optimization problems, using Opt…

---

## [Declare vector type or not / views / subarrays](https://discourse.julialang.org/t/declare-vector-type-or-not-views-subarrays/41975)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 5\
**Last updated:** [June 24, 2020, 2:44pm UTC](https://discourse.julialang.org/t/declare-vector-type-or-not-views-subarrays/41975 "2020-06-24T14:44:01Z")

</div>

Consider the example, in which I want to perform some calculations on a part of vector: julia\> f( x :: Vector{Float64} ) = (x\[1\]^2 + x\[2\]^2 + x\[3\]^2) f (generic function with 1 method) julia\> g( x :: AbstractArray ) = …

---

## [Diff! (in-place or preallocated output version of diff)](https://discourse.julialang.org/t/diff-in-place-or-preallocated-output-version-of-diff/41949)

<div class="topic-metadata">

**Author:** [@JeffFessler](https://discourse.julialang.org/u/JeffFessler)\
**Replies:** 2\
**Last updated:** [June 24, 2020, 3:16am UTC](https://discourse.julialang.org/t/diff-in-place-or-preallocated-output-version-of-diff/41949 "2020-06-24T03:16:31Z")

</div>

The Julia manual nicely makes the case for pre-allocating outputs: https://docs.julialang.org/en/latest/manual/performance-tips/#Pre-allocating-outputs-1 Yet the function diff that is used extensively in scientific com…

---

## [Pass cache to function](https://discourse.julialang.org/t/pass-cache-to-function/41934)

<div class="topic-metadata">

**Author:** [@jamblejoe](https://discourse.julialang.org/u/jamblejoe)\
**Replies:** 4\
**Last updated:** [June 23, 2020, 1:22pm UTC](https://discourse.julialang.org/t/pass-cache-to-function/41934 "2020-06-23T13:22:49Z")

</div>

Hi! I have a function which allocates a cache for calculations as function f(x::AbstractArray) cache = zeros(length(x)) # do some calculations end I now want to call this function very often (not in parallel) so I…

---

## [Custom IO performance - loading variables from byte array](https://discourse.julialang.org/t/custom-io-performance-loading-variables-from-byte-array/41814)

<div class="topic-metadata">

**Author:** [@sairus7](https://discourse.julialang.org/u/sairus7)\
**Replies:** 2\
**Last updated:** [June 23, 2020, 9:39am UTC](https://discourse.julialang.org/t/custom-io-performance-loading-variables-from-byte-array/41814 "2020-06-23T09:39:46Z")

</div>

I want to load several variables of different bitstypes from a packed byte vector. For example, Int16, Int32, Int16 from 8-byte chunk of memory. I’ve tried several approaches to find a most efficient way: Using IOBuf…

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

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