Created
December 27, 2013 18:07
-
-
Save slycoder/8150548 to your computer and use it in GitHub Desktop.
Closure speeds: Result: 0.5260329246520996
0.656851053237915
0.5118138790130615
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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