BenchmarkTools.jl
BenchmarkTools.jl copied to clipboard
Function undefined for @btime when using for loop
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
Please quote your code snippets to not ping other people.