JuliaCI / JuliaCI/BenchmarkTools.jl

Function undefined for @btime when using for loop

Open
#280 2 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.