Skip to content

Instantly share code, notes, and snippets.

@vtjnash
Created April 13, 2021 06:34
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 vtjnash/28cc68ffeb962b094fd8675bc2f6af63 to your computer and use it in GitHub Desktop.
Save vtjnash/28cc68ffeb962b094fd8675bc2f6af63 to your computer and use it in GitHub Desktop.
memory allocation policy comparison
let a = 2; global y2 = Int[]
while a < 2^42
a += a < .1*2^34 ? a : round(Int, .1*2^34)
push!(y2, a)
end
y2
end;
let a = 2; global y3 = Int[]
while a < 2^46
a += a
push!(y3, a)
end
y3
end;
let a = 2; global y4 = Int[]
while a < 2^42
a += a < .1*2^31 ? a : round(Int, .1*2^31)
push!(y4, a)
end
y4
end;
let a = 2; global y5 = Int[]
while a < 2^46
a += a < .1*2^42 ? a : round(Int, .1*2^42)
push!(y5, a)
end
end;
using Plots
let a = 2; global y = Int[]
while a < 2^42
a += 4round(Int, a^(7/8)) + a ÷ 8
push!(y, a)
end
y
end;
begin
plot(ylims=(0, 50), legend=:topleft)
plot!(searchsortedfirst.(Ref(y4), y), label="2GB")
plot!(searchsortedfirst.(Ref(y2), y), label="16GB")
plot!(searchsortedfirst.(Ref(y5), y), label="4TB")
plot!(searchsortedfirst.(Ref(y3), y), label="∞")
plot!(1:length(y), label="x=y")
end
Plots.savefig(ans, "fig.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment