Skip to content

Commit b6a85c5

Browse files
committed
Close PerfBench
1 parent 78bdb4e commit b6a85c5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/LinuxPerf.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using Formatting
77
export @measure, @measured, @pstats
88
export make_bench, enable!, disable!, reset!, reasonable_defaults, counters
99

10-
import Base: show, length, close
10+
import Base: show, length
1111

1212
macro measure(expr, args...)
1313
esc(quote
@@ -332,6 +332,8 @@ enable!(b::PerfBench) = foreach(enable!, b.groups)
332332
disable!(b::PerfBench) = foreach(disable!, b.groups)
333333
reset!(b::PerfBench) = foreach(reset!, b.groups)
334334

335+
Base.close(b::PerfBench) = foreach(close, b.groups)
336+
335337
function counters(b::PerfBench)
336338
c = Counter[]
337339
for g in b.groups
@@ -725,7 +727,9 @@ macro pstats(args...)
725727
val = $(esc(expr))
726728
disable!(bench)
727729
# trick the compiler not to eliminate the code
728-
(rand() < 0 ? val : Stats(bench))::Stats
730+
stats = rand() < 0 ? val : Stats(bench)
731+
close(bench)
732+
return stats::Stats
729733
end)()
730734
end
731735
end

0 commit comments

Comments
 (0)