We can use the script below to plot creation speed histograms for zeros
for a range of array sizes.
using Plots
benchmark_op(m) = zeros(m * 128)
anim = @animate for n = 1:1280
t = 1e6(1:10000 .|>_-> @elapsed benchmark_op(n)) / n * 1024
display(histogram(log10.(filter(k -> 88 < k < 640, [t;89;640])),
nbins=120, xlims=(1.95,2.8), ylims=(0,2000), legend=:none,
xformatter=x->round(Int, 10^x), title="array = $n KiB",
xlabel="creation speed (us / MB)", ylabel="count"))
end
gif(anim, "allocations.gif", fps = 30)
Below are the results for a Windows 10 laptop. Note how creation speeds faster than ~300 μs/MiB completely disappear when the array is larger than 1024 KiB.