JuliaCI / JuliaCI/BenchmarkTools.jl

$x should become $(Ref(x))[]?

Open
#205 8 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Julia
Stars
684
Forks
107
PR merge metrics
No merged PRs in 30d

Description

It's a bit annoying when you have to use this convoluted Ref trick to prevent the compiler from constant-folding the whole calculation (ala #130):

julia> @btime exp(1);
  0.052 ns (0 allocations: 0 bytes)

julia> @btime exp($(Ref(1))[]);
  13.785 ns (0 allocations: 0 bytes)

It would be nicer if we could just use @btime exp($1) and the $ did the trick automatically.

(Another case just came up on discourse. cc @stillyslalom)

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 reproducing the two @btime examples in the issue and reading the surrounding BenchmarkTools macro behavior. Determine how interpolated expressions are handled and define the expected behavior for @btime exp($1), including the discourse-linked vector and tuple case; done means the requested syntax avoids unwanted constant folding without requiring Ref.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
performance, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.