@@ -93,14 +93,14 @@ To run one or more specific benchmarks and record the data:
9393
9494### Running a single benchmark
9595
96- This is the easiest way to run a single benchmark.
97- It requires no setup at all and assumes nothing about the Ruby you are benchmarking.
98- It's also convenient for profiling, debugging, etc, especially since all benchmarked code runs in that process.
96+ The easiest way to run a single benchmark once is using the ` run_once.rb ` script:
9997
10098```
101- ruby benchmarks/some_benchmark.rb
99+ ./run_once.rb benchmarks/some_benchmark.rb
102100```
103101
102+ This automatically sets the environment to run the benchmark once (no warmup iterations).
103+
104104## Ractor Benchmarks
105105
106106ruby-bench supports Ractor-specific benchmarking with dedicated categories and benchmark directories.
@@ -198,23 +198,29 @@ You can find several test harnesses in the `harness/` directory:
198198* ` chain ` - a harness to chain multiple harnesses together
199199* ` mplr ` - a harness for multiple iterations with time limits
200200
201- To use a specific harness, run a benchmark script directly with ` -r ` to require the harness :
201+ To use a specific harness, use the ` run_once.rb ` script :
202202
203203```
204- # Use default harness (loads harness/default.rb automatically)
205- ruby benchmarks/railsbench/benchmark.rb
204+ # Use default harness
205+ ./run_once.rb benchmarks/railsbench/benchmark.rb
206206
207207# Use the 'once' harness
208- ruby -r./ harness/ once benchmarks/railsbench/benchmark.rb
208+ ./run_once.rb -- harness= once benchmarks/railsbench/benchmark.rb
209209
210210# Use the 'perf' harness
211- ruby -r./ harness/ perf benchmarks/railsbench/benchmark.rb
211+ ./run_once.rb -- harness= perf benchmarks/railsbench/benchmark.rb
212212
213213# Use the 'stackprof' harness
214- ruby -r./ harness/ stackprof benchmarks/railsbench/benchmark.rb
214+ ./run_once.rb -- harness= stackprof benchmarks/railsbench/benchmark.rb
215215
216216# Use the 'vernier' harness
217- ruby -r./harness/vernier benchmarks/railsbench/benchmark.rb
217+ ./run_once.rb --harness=vernier benchmarks/railsbench/benchmark.rb
218+
219+ # Pass Ruby options like --yjit (use -- separator)
220+ ./run_once.rb -- --yjit benchmarks/railsbench/benchmark.rb
221+
222+ # Combine harness option with Ruby options
223+ ./run_once.rb --harness=default -- --yjit-stats benchmarks/railsbench/benchmark.rb
218224```
219225
220226When using ` run_benchmarks.rb ` , you can specify a harness with the ` --harness ` option:
@@ -245,12 +251,11 @@ You can also use `--warmup`, `--bench`, or `--once` to set these environment var
245251./run_benchmarks.rb railsbench --once
246252```
247253
248- There is also a handy script for running benchmarks just once using
249- ` WARMUP_ITRS=0 MIN_BENCH_ITRS=1 MIN_BENCH_TIME=0 ` , for example
254+ You can also use the ` run_once.rb ` script to run benchmarks just once, for example
250255with the ` --yjit-stats ` command-line option:
251256
252257```
253- ./run_once.sh --yjit-stats benchmarks/railsbench/benchmark.rb
258+ ./run_once.rb -- --yjit-stats benchmarks/railsbench/benchmark.rb
254259```
255260
256261### Using perf
@@ -260,10 +265,10 @@ If `PERF` environment variable is present, it starts the perf subcommand after w
260265
261266``` sh
262267# Use `perf record` for both warmup and benchmark
263- perf record ruby --yjit-perf=map -r./harness/perf benchmarks/railsbench/benchmark.rb
268+ perf record ./run_once.rb --harness=perf -- -- yjit-perf=map benchmarks/railsbench/benchmark.rb
264269
265270# Use `perf record` only for benchmark
266- PERF=record ruby --yjit-perf=map -r./harness/perf benchmarks/railsbench/benchmark.rb
271+ PERF=record ./run_once.rb --harness=perf -- -- yjit-perf=map benchmarks/railsbench/benchmark.rb
267272```
268273
269274This is the only harness that uses ` run_benchmark ` 's argument, ` num_itrs_hint ` .
0 commit comments