Skip to content

Commit c82ec54

Browse files
committed
Improve chain harness documentation and error handling
1 parent 2578e51 commit c82ec54

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,25 @@ When using `run_benchmarks.rb`, you can specify a harness with the `--harness` o
260260

261261
There is also a robust but complex CI harness in [the yjit-metrics repo](https://github.com/Shopify/yjit-metrics).
262262

263+
### Chain harness
264+
265+
The `chain` harness allows you to combine multiple harnesses together. This is useful when you want to run a benchmark through multiple analysis tools or measurement approaches in sequence.
266+
267+
Use the `HARNESS_CHAIN` environment variable to specify which harnesses to chain (comma-separated, at least 2 required):
268+
269+
```bash
270+
# Chain the 'once' and 'default' harnesses (runs benchmark once, then with default iterations)
271+
HARNESS=chain HARNESS_CHAIN="once,default" ruby benchmarks/fib.rb
272+
273+
# Profile with vernier while using ractor harness
274+
HARNESS=chain HARNESS_CHAIN="vernier,ractor" ruby benchmarks-ractor/some_benchmark.rb
275+
276+
# Using run_once.rb
277+
HARNESS_CHAIN="once,default" ./run_once.rb --harness=chain benchmarks/fib.rb
278+
```
279+
280+
The harnesses are executed in the order specified, with each harness wrapping the previous one.
281+
263282
### Iterations and duration
264283

265284
With the default harness, the number of iterations and duration

harness/chain.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def run_benchmark(n, **kwargs, &block)
3434
$current_harness = h
3535
require_relative path
3636
rescue LoadError => e
37-
if e.path == path
37+
expected_path = File.expand_path(h, __dir__)
38+
if e.path == expected_path
3839
$stderr.puts "Can't find harness #{h}.rb in harness/. Exiting."
3940
exit 1
4041
end

0 commit comments

Comments
 (0)