BenchmarkTools.jl icon indicating copy to clipboard operation
BenchmarkTools.jl copied to clipboard

Function undefined for @btime when using for loop

Open bojeryd91 opened this issue 2 years ago • 2 comments

Unlike @time, @btime throws an error that fun is undefined when I run

using BenchmarkTools
f(x) = x^2; g(x) = x^3; h(x) = x^4
@btime f(2.0) # This works

for fun in (f, g, h)
    @time  fun(1.0)
    @btime fun(1.0) # This throws UndefVarError: fun not defined
end

I am running BenchmarkTools v1.3.1 and Julia 1.6.0

bojeryd91 avatar Mar 13 '22 18:03 bojeryd91

Please quote your code snippets to not ping other people.

vchuravy avatar Mar 14 '22 01:03 vchuravy