File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change 1- require_relative "../harness/harness-common"
1+ # frozen_string_literal: true
2+ #
3+ # This is a relatively minimal harness meant for use with Linux perf(1).
4+ # Example usage:
5+ #
6+ # $ PERF='record -e cycles' ruby -Iharness-perf benchmarks/fib.rb
7+ #
8+ # When recording with perf(1), make sure the benchmark runs long enough; you
9+ # can tweak the MIN_BENCH_ITRS environment variable to lengthen the run. A race
10+ # condition is possible where the benchmark finishes before the perf(1)
11+ # subprocess has a chance to attach, in which case perf outputs no profile.
212
3- # This harness is meant for use with perf stat
4- # All it does is run the benchmark a number of times
13+ require_relative "../harness/harness-common"
514
615# Takes a block as input
716def run_benchmark ( num_itrs_hint )
@@ -23,6 +32,9 @@ def run_benchmark(num_itrs_hint)
2332 cmd . push ( '-o' , File . expand_path ( '../perf.data' , __dir__ ) )
2433 end
2534 pid = Process . spawn ( *cmd )
35+ # _Race_: we, the parent process might finish before perf attaches.
36+ # Ideally, we would wait for attachment before running benchmark
37+ # iterations, but implementing that seems complicated.
2638 end
2739
2840 # Run benchmark
You can’t perform that action at this time.
0 commit comments