Skip to content

Commit 34ca728

Browse files
topolarityZentrik
authored andcommitted
Don't leak PerfBench in @measure
It's important not to leak these perf events, due to limited PMU resources on the system. Without this fix, running the two README examples back-to-back on my system leads to: ``` ┌ Warning: Some events are not measured └ @ LinuxPerf ~/.julia/dev/LinuxPerf/src/LinuxPerf.jl:892 ... ┌ instructions NA 0.0% └ branch-misses NA 0.0% ```
1 parent e19e1f2 commit 34ca728

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/LinuxPerf.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ macro measure(expr, args...)
1212
esc(quote
1313
local bench
1414
_, bench = $LinuxPerf.@measured($expr, $(args...))
15-
$counters(bench)
15+
local counts = $counters(bench)
16+
$close(bench)
17+
counts
1618
end)
1719
end
1820
macro measured(expr, events = reasonable_defaults)

0 commit comments

Comments
 (0)