@@ -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### Benchmark organization
105105
106106Benchmarks can be organized in three ways:
@@ -225,23 +225,29 @@ You can find several test harnesses in the `harness/` directory:
225225* ` chain ` - a harness to chain multiple harnesses together
226226* ` mplr ` - a harness for multiple iterations with time limits
227227
228- To use a specific harness, run a benchmark script directly with ` -r ` to require the harness :
228+ To use a specific harness, use the ` run_once.rb ` script :
229229
230230```
231- # Use default harness (loads harness/default.rb automatically)
232- ruby benchmarks/railsbench/benchmark.rb
231+ # Use default harness
232+ ./run_once.rb benchmarks/railsbench/benchmark.rb
233233
234234# Use the 'once' harness
235- ruby -r./ harness/ once benchmarks/railsbench/benchmark.rb
235+ ./run_once.rb -- harness= once benchmarks/railsbench/benchmark.rb
236236
237237# Use the 'perf' harness
238- ruby -r./ harness/ perf benchmarks/railsbench/benchmark.rb
238+ ./run_once.rb -- harness= perf benchmarks/railsbench/benchmark.rb
239239
240240# Use the 'stackprof' harness
241- ruby -r./ harness/ stackprof benchmarks/railsbench/benchmark.rb
241+ ./run_once.rb -- harness= stackprof benchmarks/railsbench/benchmark.rb
242242
243243# Use the 'vernier' harness
244- ruby -r./harness/vernier benchmarks/railsbench/benchmark.rb
244+ ./run_once.rb --harness=vernier benchmarks/railsbench/benchmark.rb
245+
246+ # Pass Ruby options like --yjit (use -- separator)
247+ ./run_once.rb -- --yjit benchmarks/railsbench/benchmark.rb
248+
249+ # Combine harness option with Ruby options
250+ ./run_once.rb --harness=default -- --yjit-stats benchmarks/railsbench/benchmark.rb
245251```
246252
247253When using ` run_benchmarks.rb ` , you can specify a harness with the ` --harness ` option:
@@ -272,12 +278,11 @@ You can also use `--warmup`, `--bench`, or `--once` to set these environment var
272278./run_benchmarks.rb railsbench --once
273279```
274280
275- There is also a handy script for running benchmarks just once using
276- ` WARMUP_ITRS=0 MIN_BENCH_ITRS=1 MIN_BENCH_TIME=0 ` , for example
281+ You can also use the ` run_once.rb ` script to run benchmarks just once, for example
277282with the ` --yjit-stats ` command-line option:
278283
279284```
280- ./run_once.sh --yjit-stats benchmarks/railsbench/benchmark.rb
285+ ./run_once.rb -- --yjit-stats benchmarks/railsbench/benchmark.rb
281286```
282287
283288### Using perf
@@ -287,10 +292,10 @@ If `PERF` environment variable is present, it starts the perf subcommand after w
287292
288293``` sh
289294# Use `perf record` for both warmup and benchmark
290- perf record ruby --yjit-perf=map -r./harness/perf benchmarks/railsbench/benchmark.rb
295+ perf record ./run_once.rb --harness=perf -- -- yjit-perf=map benchmarks/railsbench/benchmark.rb
291296
292297# Use `perf record` only for benchmark
293- PERF=record ruby --yjit-perf=map -r./harness/perf benchmarks/railsbench/benchmark.rb
298+ PERF=record ./run_once.rb --harness=perf -- -- yjit-perf=map benchmarks/railsbench/benchmark.rb
294299```
295300
296301This is the only harness that uses ` run_benchmark ` 's argument, ` num_itrs_hint ` .
0 commit comments