Skip to content

Commit

Permalink
Use @noinline from Compat in linux_perf_func
Browse files Browse the repository at this point in the history
  • Loading branch information
Zentrik committed May 2, 2024
1 parent b157449 commit b1bc53c
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/execution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b1bc53c

Please sign in to comment.