Skip to content

Commit 697259a

Browse files
committed
Close PerfBench
1 parent ca42e11 commit 697259a

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
@@ -311,6 +311,8 @@ enable!(b::PerfBench) = foreach(enable!, b.groups)
311311
disable!(b::PerfBench) = foreach(disable!, b.groups)
312312
reset!(b::PerfBench) = foreach(reset!, b.groups)
313313

314+
Base.close(b::PerfBench) = foreach(close, b.groups)
315+
314316
function counters(b::PerfBench)
315317
c = Counter[]
316318
for g in b.groups
@@ -704,7 +706,9 @@ macro pstats(args...)
704706
val = $(esc(expr))
705707
disable!(bench)
706708
# trick the compiler not to eliminate the code
707-
(rand() < 0 ? val : Stats(bench))::Stats
709+
stats = rand() < 0 ? val : Stats(bench)
710+
close(bench)
711+
return stats::Stats
708712
end)()
709713
end
710714
end

0 commit comments

Comments
 (0)