Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --bench and --warmup flags #261

Merged
merged 5 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ can be controlled by the following environment variables:
* `MIN_BENCH_ITRS`: The minimum number of benchmark iterations (default: 10)
* `MIN_BENCH_TIME`: The minimum seconds for benchmark (default: 10)

You can also use `--warmup` and `--bench` to set these environment variables:

```sh
# same as: WARMUP_ITRS=2 MIN_BENCH_ITRS=3 MIN_BENCH_TIME=0 ./run_benchmarks.rb railsbench
./run_benchmarks.rb railsbench --warmup=2 --bench=3
```

There is a handy script for running benchmarks just once using
`WARMUP_ITRS=0 MIN_BENCH_ITRS=1 MIN_BENCH_TIME=0`, for example
with the `--yjit-stats` command-line option:
Expand Down
9 changes: 9 additions & 0 deletions run_benchmarks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,15 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat
args.harness = v
end

opts.on("--warmup=N", "the number of warmup iterations for the default harness (default: 15)") do |n|
ENV["WARMUP_ITRS"] = n
end

opts.on("--bench=N", "the number of benchmark iterations for the default harness (default: 10). Also defaults MIN_BENCH_TIME to 0.") do |n|
ENV["MIN_BENCH_ITRS"] = n
ENV["MIN_BENCH_TIME"] ||= "0"
k0kubun marked this conversation as resolved.
Show resolved Hide resolved
end

opts.on("--yjit_opts=OPT_STRING", "string of command-line options to run YJIT with (ignored if you use -e)") do |str|
args.yjit_opts=str
end
Expand Down
Loading