From b1bc53c44329bf5d36ece53558030735907cfc78 Mon Sep 17 00:00:00 2001 From: Zentrik Date: Thu, 2 May 2024 22:29:35 +0100 Subject: [PATCH] Use `@noinline` from Compat in linux_perf_func --- src/execution.jl | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) 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)