diff --git a/src/execution.jl b/src/execution.jl index 7f082e05..75017e4c 100644 --- a/src/execution.jl +++ b/src/execution.jl @@ -609,21 +609,25 @@ function generate_benchmark_definition( ) try - @noinline $(setup) + $BenchmarkTools.@noinline $(setup) __evals = __params.evals # Isolate code so that e.g. setup doesn't cause different code to be generated by e.g. changing register allocation # Unfortunately it still does, e.g. if you define a variable in setup then it's passed into invocation adding a few instructions - @noinline (function (__evals) - $LinuxPerf.enable_all!() - # We'll run it evals times. - @noinline __return_val_2 = $(invocation) - for __iter in 2:__evals - @noinline $(invocation) + $BenchmarkTools.@noinline ( + function (__evals) + $LinuxPerf.enable_all!() + # We'll run it evals times. + $BenchmarkTools.@noinline __return_val_2 = $(invocation) + for __iter in 2:__evals + $BenchmarkTools.@noinline $(invocation) + end + $LinuxPerf.disable_all!() + # trick the compiler not to eliminate the code + return __return_val_2 end - $LinuxPerf.disable_all!() - # trick the compiler not to eliminate the code - return __return_val_2 - end)(__evals) + )( + __evals + ) return $LinuxPerf.Stats(__linux_perf_bench) finally close(__linux_perf_bench)