JuliaCI / BenchmarkTools.jl

A benchmarking framework for the Julia language
Other
610 stars 100 forks source link

`setup`/`teardown` doesn't allow multiple assignment syntax inside Tuple #44

Open jrevels opened 7 years ago

jrevels commented 7 years ago
julia> using BenchmarkTools

# this should work, but doesn't
julia> @benchmark (a + b + c) setup=(a,b,c=1,2,3)
ERROR: syntax: assignment not allowed inside tuple
 in generate_benchmark_definition(::Module, ::Array{Symbol,1}, ::Array{Symbol,1}, ::Expr, ::Expr, ::Void, ::BenchmarkTools.Parameters) at /Users/jarrettrevels/.julia/v0.5/BenchmarkTools/src/execution.jl:282

julia> @benchmark (a + b + c) setup=begin a,b,c=1,2,3 end
BenchmarkTools.Trial:
  memory estimate:  0 bytes
  allocs estimate:  0
  --------------
  minimum time:     1.645 ns (0.00% GC)
  median time:      1.962 ns (0.00% GC)
  mean time:        1.967 ns (0.00% GC)
  maximum time:     4.511 ns (0.00% GC)
  --------------
  samples:          10000
  evals/sample:     1000
  time tolerance:   5.00%
  memory tolerance: 1.00%
jrevels commented 7 years ago

It might be the case that we can't easily "fix" this due to how things parse, so the action item here is to change the documentation to use begin...end instead of parens for setup/teardown delimiters.

gdalle commented 1 year ago

I added this warning to the docs in PR #312 after stumbling upon the same problem