Skip to content

Instantly share code, notes, and snippets.

View slycoder's full-sized avatar

Jonathan Chang slycoder

View GitHub Profile
@slycoder
slycoder / gist:8143200
Last active January 1, 2016 12:18
Better example. I understand macros now I think.
macro singleton(ex)
v = eval(ex)
:($v)
end
function demo()
y = @singleton zeros(Int64, 1000000)
for ii in 1:1000000
@inbounds y[ii] += 3
end
@slycoder
slycoder / gist:8150548
Created December 27, 2013 18:07
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