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

@btime in local scope throws UndefVarError

Open chunjiw opened this issue 3 years ago • 3 comments

using BenchmarkTools
x = 4
let y = x
    @btime y^2
end

or

using BenchmarkTools
x = 4
let 
    y = x
    @btime y^2
end

Throws UndefVarError saying y is not defined. @time works with no problem.

chunjiw avatar Jul 11 '22 23:07 chunjiw

I should have read the README doc first...

chunjiw avatar Jul 11 '22 23:07 chunjiw

(After reading the doc) README doc says we should use interpolation, but didn't say error thrown if not interpolate. I feel like the examples should not throw errors, instead just give the benchmark result, just like when @btime is applied to a global variable.

Reopen this issue.

chunjiw avatar Jul 12 '22 00:07 chunjiw