It should probably be the 1st faq. It's the first performance tip though: http://julia.readthedocs.org/en/latest/manual/performance-tips/
Put your code in functions (or liberally use const). Globals are slow. On Dec 27, 2014 10:24 PM, "Bob Quazar" <[email protected]> wrote: > The devectorized code below should be much faster than equivalent > vectorized code, according to "Fast Numeric Computation in Julia > <http://julialang.org/blog/2013/09/fast-numeric/>" on the official > julialang.org web site. But I find just the opposite! > > julia> x = randn(10000000); >> julia> y = randn(10000000); >> julia> r = zeros(10000000); >> julia> @time r[:] = exp(-abs(x-y)); >> elapsed time: 1.233813455 seconds (320000432 bytes allocated, 14.20% gc >> time) >> julia> @time for i = 1:length(x) >> r[i] = exp(-abs(x[i]-y[i])) >> end >> elapsed time: 10.326934093 seconds (1599983704 bytes allocated, 21.29% gc >> time) > > > Can someone explain what's going on? The devectorized version appears to > allocate 5x as much memory. > > Thanks much! > >
