Skip to content

Instantly share code, notes, and snippets.

@slycoder
Created December 27, 2013 18:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slycoder/8150548 to your computer and use it in GitHub Desktop.
Save slycoder/8150548 to your computer and use it in GitHub Desktop.
Closure speeds: Result: 0.5260329246520996 0.656851053237915 0.5118138790130615
begin
local y::Vector{Int64} = zeros(Int64, 1000000)
global demo2
function demo2()
x = y
for ii in 1:1000000
@inbounds x[ii] += 3
end
return x
end
end
begin
local y::Vector{Int64} = zeros(Int64, 1000000)
global demo2slow
function demo2slow()
for ii in 1:1000000
@inbounds y[ii] += 3
end
return y
end
end
bar = zeros(Int64, 1000000)
function demo3(bar)
for ii in 1:1000000
@inbounds bar[ii] += 3
end
return bar
end
start = time()
for i = 1:500
demo2()
end
println(time() - start)
start = time()
for i = 1:500
demo2slow()
end
println(time() - start)
start = time()
for i = 1:500
demo3(bar)
end
println(time() - start)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment