Skip to content

Commit

Permalink
Add --bench and --warmup flags
Browse files Browse the repository at this point in the history
  • Loading branch information
k0kubun committed Jan 6, 2024
1 parent 49cd7f6 commit 9cbff11
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ 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=0 MIN_BENCH_ITRS=1 MIN_BENCH_TIME=0 ./run_benchmarks.rb railsbench
./run_benchmarks.rb railsbench --bench=1

# 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
10 changes: 10 additions & 0 deletions run_benchmarks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,16 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat
args.harness = v
end

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

opts.on("--bench=N", "the number of benchmark iterations (default: 10)") do |n|
ENV["WARMUP_ITRS"] ||= "0"
ENV["MIN_BENCH_ITRS"] = n
ENV["MIN_BENCH_TIME"] ||= "0"
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

0 comments on commit 9cbff11

Please sign in to comment.