Skip to content

Instantly share code, notes, and snippets.

@Gnimuc
Created January 13, 2016 14:16
Show Gist options
  • Save Gnimuc/e01cd9423bb0a0f66c24 to your computer and use it in GitHub Desktop.
Save Gnimuc/e01cd9423bb0a0f66c24 to your computer and use it in GitHub Desktop.
[SO]Julia vs MATLAB: Why is my Julia code so slow?
using Dierckx
function foo()
x = [0., 1., 2., 3., 4.]
y = [-1., 0., 7., 26., 63.]
spl = Spline1D(x, y)
a = evaluate(spl, ones(10000))
reshape(a,100,100)
end
function bar()
for i=1:1000
foo()
end
end
@time bar()
@Gnimuc
Copy link
Author

Gnimuc commented Jan 13, 2016

julia> @time bar()
  0.492527 seconds (18.00 k allocations: 155.274 MB, 2.68% gc time)
julia> versioninfo()
Julia Version 0.4.2
Commit bb73f34 (2015-12-06 21:47 UTC)
Platform Info:
  System: Darwin (x86_64-apple-darwin13.4.0)
  CPU: Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment