Skip to content

Commit d138ff8

Browse files
committed
Add --no-sudo option to skip all operations that require sudo
When running benchmarks on machines without sudo access, the CPU configuration (turbo boost, min_perf_pct, frequency governor) cannot be set or verified. The --no-sudo flag skips the entire CPUConfig setup, which includes both the sudo-dependent writes and the checks that exit when the expected configuration isn't detected.
1 parent ac3597f commit d138ff8

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

lib/argument_parser.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class ArgumentParser
1919
:no_pinning,
2020
:force_pinning,
2121
:turbo,
22+
:no_sudo,
2223
:skip_yjit,
2324
:skip_zjit,
2425
:with_pre_init,
@@ -158,6 +159,10 @@ def parse(argv)
158159
opts.on("--turbo", "don't disable CPU turbo boost") do
159160
args.turbo = true
160161
end
162+
163+
opts.on("--no-sudo", "skip all operations that require sudo") do
164+
args.no_sudo = true
165+
end
161166
end.parse!(argv)
162167

163168
# Remaining arguments are treated as benchmark name filters
@@ -223,6 +228,7 @@ def default_args
223228
no_pinning: false,
224229
force_pinning: false,
225230
turbo: false,
231+
no_sudo: false,
226232
skip_yjit: false,
227233
skip_zjit: true,
228234
with_pre_init: nil,

lib/benchmark_runner/cli.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def initialize(args)
2121
end
2222

2323
def run
24-
CPUConfig.configure_for_benchmarking(turbo: args.turbo)
24+
CPUConfig.configure_for_benchmarking(turbo: args.turbo) unless args.no_sudo
2525

2626
# Create the output directory
2727
FileUtils.mkdir_p(args.out_path)

test/argument_parser_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def setup_mock_ruby(path)
5252
assert_equal false, args.graph
5353
assert_equal false, args.no_pinning
5454
assert_equal false, args.turbo
55+
assert_equal false, args.no_sudo
5556
assert_equal false, args.skip_yjit
5657
end
5758
end
@@ -454,6 +455,15 @@ def setup_mock_ruby(path)
454455
end
455456
end
456457

458+
describe '--no-sudo option' do
459+
it 'sets no_sudo flag' do
460+
parser = ArgumentParser.new
461+
args = parser.parse(['--no-sudo'])
462+
463+
assert_equal true, args.no_sudo
464+
end
465+
end
466+
457467
describe 'remaining arguments' do
458468
it 'treats remaining arguments as name filters' do
459469
parser = ArgumentParser.new

0 commit comments

Comments
 (0)