julia> let
a = rand(10)
setup = quote
x = deepcopy($a)
end
t1 = @eval @benchmark sum(x) setup=$setup evals=1
end
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
Range (min … max): 17.000 ns … 132.000 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 26.000 ns ┊ GC (median): 0.00%
Time (mean ± σ): 24.744 ns ± 3.659 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
▇ ▂ █ ▄
▄▁▁▁█▁▁▁▁▃▁▁▁▂▁▁▁▁▂▁▁▁▁▂▁▁▁█▁▁▁▁█▁▁▁▃▁▁▁▁█▁▁▁▁█▁▁▁█▁▁▁▁▆▁▁▁▃ ▃
17 ns Histogram: frequency by time 30 ns <
Memory estimate: 0 bytes, allocs estimate: 0.
julia> let
a = rand(10)
@benchmark sum(x) setup=(x = deepcopy($a)) evals=1
end
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
Range (min … max): 17.000 ns … 17.739 μs ┊ GC (min … max): 0.00% … 0.00%
Time (median): 24.000 ns ┊ GC (median): 0.00%
Time (mean ± σ): 26.664 ns ± 177.178 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
█ █
▂▁▁▁▃▁▁▁▁▂▁▁▁▂▁▁▁▁▂▁▁▁▁▂▁▁▁█▁▁▁▁█▁▁▁▃▁▁▁▁█▁▁▁▁▄▁▁▁▃▁▁▁▁▃▁▁▁▃ ▂
17 ns Histogram: frequency by time 30 ns <
Memory estimate: 0 bytes, allocs estimate: 0.
1 Like