Why does @benchmark take so long even when evals is manually specified?
using BenchmarkTools
count = 0
@elapsed @benchmark (global count += 1; sleep(.05)) evals=1 samples=10 # 1.68
@elapsed for i in 1:count; sleep(.05) end # 0.587
count # 11
Why does @benchmark take so long even when evals is manually specified?
using BenchmarkTools
count = 0
@elapsed @benchmark (global count += 1; sleep(.05)) evals=1 samples=10 # 1.68
@elapsed for i in 1:count; sleep(.05) end # 0.587
count # 11
Does it have to do with Base.GC.gc()
being called before running the test?
BenchmarkTools does a tuning step to figure out how many evaluations to perform; you can save these results, however, to re-use them: Manual ยท BenchmarkTools.jl
edit: sorry, just realized you mentioned evals
being manually specified which would skip the tuning step. Not sure then; maybe the GCing explains it like you said.