Yes, I should have done that before I posted ... I apologize ...
However, as said in my previous answer, wrapping my bench in a function
doesn't change the results. So I still don't know if I'm doing something
wrong (and what ...) :
julia> using DataFrames
julia> using Gadfly
julia> function bench_cpu_regarding_n()
N = [ 1,2,3,4,5,6,7,8,9,
10,20,30,40,50,60,70,80,90,100,200,300,400,500,750,
1_000,2_500,5_000,7_500,10_000,100_000,1_000_000]
cpu = []
for n in N
n==1 ? a = pi : a = rand(n)
sqrt(a)
gc()
gc_enable(false)
t = mean([@elapsed sqrt(a) for i=1:100])*(1e9/n)
gc_enable(true)
push!(cpu,t)
println(round(cpu[end]))
end
df = DataFrame()
df[:N] = N
df[:CPU] = cpu
path = Pkg.dir("MKL") * "/benchmark/"
p = Gadfly.plot(
layer(df,x="N",y="CPU",Geom.line),
Scale.x_log10,
Guide.xlabel("n-element vector"),
Guide.ylabel("CPU time in nsec/element"),
Guide.title("CPU time for sqrt(X) where X =
Float64[] with n elements"))
draw(PNG(path*"sqrt_cpu(n).png", 20cm, 20cm), p)
p
end
bench_cpu_regarding_n (generic function with 1 method)
julia> @time bench_cpu_regarding_n()
281.0
155.0
109.0
81.0
95.0
67.0
50.0
79.0
40.0
36.0
57.0
24.0
22.0
13.0
12.0
...