diff --git a/src/LinuxPerf.jl b/src/LinuxPerf.jl index 3f37499..995574b 100644 --- a/src/LinuxPerf.jl +++ b/src/LinuxPerf.jl @@ -1142,7 +1142,12 @@ macro pstats(args...) val = $(esc(expr)) disable_all!() # trick the compiler not to eliminate the code - stats = rand() < 0 ? val : Stats(bench) + @static if isdefined(Base, :donotdelete) + Base.donotdelete(val) + stats = Stats(bench) + else + stats = (@noinline rand()) < 0 ? val : Stats(bench) + end return stats::Stats catch rethrow()