Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/argument_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class ArgumentParser
:no_pinning,
:force_pinning,
:turbo,
:no_sudo,
:skip_yjit,
:skip_zjit,
:with_pre_init,
Expand Down Expand Up @@ -158,6 +159,10 @@ def parse(argv)
opts.on("--turbo", "don't disable CPU turbo boost") do
args.turbo = true
end

opts.on("--no-sudo", "skip all operations that require sudo") do
args.no_sudo = true
end
end.parse!(argv)

# Remaining arguments are treated as benchmark name filters
Expand Down Expand Up @@ -223,6 +228,7 @@ def default_args
no_pinning: false,
force_pinning: false,
turbo: false,
no_sudo: false,
skip_yjit: false,
skip_zjit: true,
with_pre_init: nil,
Expand Down
2 changes: 1 addition & 1 deletion lib/benchmark_runner/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def initialize(args)
end

def run
CPUConfig.configure_for_benchmarking(turbo: args.turbo)
CPUConfig.configure_for_benchmarking(turbo: args.turbo) unless args.no_sudo

# Create the output directory
FileUtils.mkdir_p(args.out_path)
Expand Down
10 changes: 10 additions & 0 deletions test/argument_parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def setup_mock_ruby(path)
assert_equal false, args.graph
assert_equal false, args.no_pinning
assert_equal false, args.turbo
assert_equal false, args.no_sudo
assert_equal false, args.skip_yjit
end
end
Expand Down Expand Up @@ -454,6 +455,15 @@ def setup_mock_ruby(path)
end
end

describe '--no-sudo option' do
it 'sets no_sudo flag' do
parser = ArgumentParser.new
args = parser.parse(['--no-sudo'])

assert_equal true, args.no_sudo
end
end

describe 'remaining arguments' do
it 'treats remaining arguments as name filters' do
parser = ArgumentParser.new
Expand Down
Loading