Skip to content

Instantly share code, notes, and snippets.

@stillyslalom
Last active November 15, 2015 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stillyslalom/e8a5ad6bc93928ef2109 to your computer and use it in GitHub Desktop.
Save stillyslalom/e8a5ad6bc93928ef2109 to your computer and use it in GitHub Desktop.
using Plots
function test_push(n)
A = [1]
tic()
for i = 1:n
push!(A,1)
end
toc()
end
function test_copy(n)
A = [1]
tic()
for i = 1:n
A = [A;1]
end
toc()
end
plot(floor(logspace(1,4,10)),[test_push,test_copy],
labels=["push!","copy"]',title="elapsed time",
xaxis=("array size", :log10),yaxis=("seconds",:log10))
savefig(dirname(@__FILE__)*"\\push_v_copy")
plot(floor(logspace(1,4,10)),[meshalloc,broadalloc],
labels=["push!","copy"]',title="memory allocation",
xaxis=("array size", :log10),yaxis=("bytes allocated",:log10))
savefig(dirname(@__FILE__)*"\\push_v_copy_malloc")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment