Skip to content

Commit b118a4a

Browse files
committed
Close perf when done to prevent too many files open error
1 parent c182d07 commit b118a4a

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/execution.jl

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -582,19 +582,25 @@ function generate_benchmark_definition(
582582
__linux_perf_bench = BenchmarkTools.LinuxPerf.make_bench_threaded(
583583
__linux_perf_groups; threads=$(params.linux_perf_options.threads)
584584
)
585-
BenchmarkTools.LinuxPerf.enable!(__linux_perf_bench)
586-
# We'll just run it one time.
587-
__return_val_2 = $(invocation)
588-
BenchmarkTools.LinuxPerf.disable!(__linux_perf_bench)
589-
# trick the compiler not to eliminate the code
590-
if rand() < 0
591-
__linux_perf_stats = __return_val_2
592-
else
593-
__linux_perf_stats = BenchmarkTools.LinuxPerf.Stats(
594-
__linux_perf_bench
595-
)
585+
try
586+
BenchmarkTools.LinuxPerf.enable!(__linux_perf_bench)
587+
# We'll just run it one time.
588+
__return_val_2 = $(invocation)
589+
BenchmarkTools.LinuxPerf.disable!(__linux_perf_bench)
590+
# trick the compiler not to eliminate the code
591+
if rand() < 0
592+
__linux_perf_stats = __return_val_2
593+
else
594+
__linux_perf_stats = BenchmarkTools.LinuxPerf.Stats(
595+
__linux_perf_bench
596+
)
597+
end
598+
catch
599+
rethrow()
600+
finally
601+
close(__linux_perf_bench)
602+
$(teardown)
596603
end
597-
$(teardown)
598604
else
599605
__return_val_2 = nothing
600606
__linux_perf_stats = nothing

0 commit comments

Comments
 (0)