Skip to content

Commit 51a26df

Browse files
authored
Add --turbo option to skip disabling turbo (#307)
1 parent e0f01b7 commit 51a26df

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

run_benchmarks.rb

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,20 @@ def have_yjit?(ruby)
5757
ruby_version.downcase.include?("yjit")
5858
end
5959

60-
def set_bench_config
60+
def set_bench_config(turbo:)
6161
if File.exist?('/sys/devices/system/cpu/intel_pstate') # Intel
6262
# sudo requires the flag '-S' in order to take input from stdin
63-
check_call("sudo -S sh -c 'echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo'") unless intel_no_turbo?
63+
check_call("sudo -S sh -c 'echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo'") unless turbo || intel_no_turbo?
6464
check_call("sudo -S sh -c 'echo 100 > /sys/devices/system/cpu/intel_pstate/min_perf_pct'") unless intel_perf_100pct?
6565
elsif File.exist?('/sys/devices/system/cpu/cpufreq/boost') # AMD
66-
check_call("sudo -S sh -c 'echo 0 > /sys/devices/system/cpu/cpufreq/boost'") unless amd_no_boost?
66+
check_call("sudo -S sh -c 'echo 0 > /sys/devices/system/cpu/cpufreq/boost'") unless turbo || amd_no_boost?
6767
check_call("sudo -S cpupower frequency-set -g performance") unless performance_governor?
6868
end
6969
end
7070

71-
def check_pstate
71+
def check_pstate(turbo:)
7272
if File.exist?('/sys/devices/system/cpu/intel_pstate') # Intel
73-
unless intel_no_turbo?
73+
unless turbo || intel_no_turbo?
7474
puts("You forgot to disable turbo:")
7575
puts(" sudo sh -c 'echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo'")
7676
exit(-1)
@@ -82,7 +82,7 @@ def check_pstate
8282
exit(-1)
8383
end
8484
elsif File.exist?('/sys/devices/system/cpu/cpufreq/boost') # AMD
85-
unless amd_no_boost?
85+
unless turbo || amd_no_boost?
8686
puts("You forgot to disable boost:")
8787
puts(" sudo sh -c 'echo 0 > /sys/devices/system/cpu/cpufreq/boost'")
8888
exit(-1)
@@ -309,6 +309,7 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat
309309
rss: false,
310310
graph: false,
311311
no_pinning: false,
312+
turbo: false,
312313
})
313314

314315
OptionParser.new do |opts|
@@ -398,6 +399,10 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat
398399
opts.on("--no-pinning", "don't pin ruby to a specific CPU core") do
399400
args.no_pinning = true
400401
end
402+
403+
opts.on("--turbo", "don't disable CPU turbo boost") do
404+
args.turbo = true
405+
end
401406
end.parse!
402407

403408
# Remaining arguments are treated as benchmark name filters
@@ -416,10 +421,10 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat
416421
end
417422

418423
# Disable CPU frequency scaling
419-
set_bench_config
424+
set_bench_config(turbo: args.turbo)
420425

421426
# Check pstate status
422-
check_pstate
427+
check_pstate(turbo: args.turbo)
423428

424429
# Create the output directory
425430
FileUtils.mkdir_p(args.out_path)

0 commit comments

Comments
 (0)