JuliaCI / JuliaCI/BenchmarkTools.jl
Function undefined for @btime when using for loop
Open
Nobody has claimed this yet.
bug
- Dominant language
- Julia
- Stars
- 684
- Forks
- 107
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied Julia reproducer with BenchmarkTools 1.3.1 and compare the @time and @btime calls inside the loop. Trace the @btime macro entry point to understand why fun is not available there; done means the loop benchmarks each function without the reported UndefVarError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- performance
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100