Last active
November 15, 2015 23:38
-
-
Save stillyslalom/e8a5ad6bc93928ef2109 to your computer and use it in GitHub Desktop.
This file contains 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
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