diff --git a/harness/harness-common.rb b/harness/harness-common.rb index f225f0cf..65c33d6a 100644 --- a/harness/harness-common.rb +++ b/harness/harness-common.rb @@ -153,6 +153,12 @@ def return_results(warmup_iterations, bench_iterations) end write_json_file(yjit_bench_results) + + if ENV["YJIT_BENCH_SHOW_DEBUG_COUNTERS"]=="1" + ENV["RUBY_DEBUG_COUNTER_DISABLE"] = "0" + RubyVM.show_debug_counters if defined?(RubyVM.show_debug_counters) + ENV["RUBY_DEBUG_COUNTER_DISABLE"] = "1" + end end def write_json_file(yjit_bench_results) diff --git a/harness/harness.rb b/harness/harness.rb index f1dd8405..259e4730 100644 --- a/harness/harness.rb +++ b/harness/harness.rb @@ -39,6 +39,7 @@ def run_benchmark(_num_itrs_hint, &block) header = "itr: time" RubyVM::YJIT.reset_stats! if defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled? + RubyVM.reset_debug_counters if defined?(RubyVM.reset_debug_counters) # If $YJIT_BENCH_STATS is given, print the diff of these stats at each iteration. if ENV["YJIT_BENCH_STATS"] diff --git a/run_benchmarks.rb b/run_benchmarks.rb index a4eafbdc..ffa86d52 100755 --- a/run_benchmarks.rb +++ b/run_benchmarks.rb @@ -420,6 +420,12 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat opts.on("--turbo", "don't disable CPU turbo boost") do args.turbo = true end + + opts.on("--show-debug-counters", "Show debug counters (if available) after each benchmark has run") do + # disable showing debug counters for any subprocesses of ruby that we run except the benchmark scripts themselves + ENV["RUBY_DEBUG_COUNTER_DISABLE"] = "1" + ENV["YJIT_BENCH_SHOW_DEBUG_COUNTERS"] = "1" + end end.parse! # Remaining arguments are treated as benchmark name filters