Created
May 17, 2017 11:56
-
-
Save KristofferC/9db93bfae898c8942d275ca360ab8f62 to your computer and use it in GitHub Desktop.
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
function f1(vs) | |
z = 0.0 | |
for v in vs | |
for x in v | |
z += x | |
end | |
end | |
return z | |
end | |
function f2(vs) | |
z = 0.0 | |
for v in vs | |
(v -> begin | |
for x in v | |
z += x | |
end | |
end)(v) | |
end | |
return z | |
end | |
function f3(vs) | |
z = 0.0 | |
for v in vs | |
z += _f3(v) | |
end | |
return z | |
end | |
function _f3(v) | |
_z = 0.0 | |
for x in v | |
_z += x | |
end | |
return _z | |
end | |
vs = convert(Vector{Any}, [rand(10^5), rand(Int, 10^5), rand(Float32, 10^5)]); | |
@time f1(vs) | |
@time f2(vs) | |
@time f3(vs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment