Skip to content

Commit 101f9d1

Browse files
committed
DOC: matmul-param: show --table --all
1 parent b6d862c commit 101f9d1

1 file changed

Lines changed: 71 additions & 7 deletions

File tree

‎examples/matmul-params/README.md‎

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ We can select specific cases by either giving exact parameter values or a regex.
6565
the benchmark with string arguments, we have to use the quoted strings in CLI.
6666

6767
```
68-
$ bx bench bench_matmul.py bench_matmul $QUICK # a function's name: all six
69-
$ bx bench bench_matmul.py "bench_matmul(100, 'torch')" $QUICK # one combination
70-
$ bx bench bench_matmul.py --filter "'torch'" $QUICK # a regex: the three torch cases
68+
$ bx bench bench_matmul.py bench_matmul # a function's name: all six
69+
$ bx bench bench_matmul.py "bench_matmul(100, 'torch')" # one combination
70+
$ bx bench bench_matmul.py --filter "'torch'" # a regex: the three torch cases
7171
```
7272

7373
A regex is searched in `bench_matmul(10, 'torch')`, the function's name and the argument
@@ -84,7 +84,7 @@ We can of course, visually inspect the output above, and try to guesstimate the
8484
`benchx` however provides a better way to perform a comparison and run a statistical analysis to come up with
8585
a _comparison verdict_ (faster, slower or indeterminate). The relevant CLI command is `bx compare`.
8686

87-
## A first attempt (which fails)
87+
## A first attempt (that fails)
8888

8989
We have already run benchmarks for both numpy and torch, can we use them to run the comparison via `bx compare`?
9090
First, we need to find out the *run key*. We did not specify it explicitly, thus it has been automatically
@@ -186,12 +186,76 @@ In general, for our quick-and-dirty setting, `$QUICK`, results are expected to s
186186
noise. A real comparison will need to use at least the default settings or actually larger number of rounds and values.
187187

188188

189+
### Show all comparison results, as a table
190+
191+
The output above only shows "effects" and does not show actual timings. To show both, we could have
192+
added `--table --all` to the `bx compare` call. Given that we did not add it, we can rerun the
193+
comparison (but not the benchmarks themselves!) in the so-called *run mode*, where it pulls the
194+
data to compare from the store.
195+
196+
First, instead of the benchmark suite, it needs the run key for the precomputed data.
197+
Then, we give it the same `--profile variants --vary xp` arguments to specify what to
198+
compare, and also we tell it which side is the baseline, `--baseline "'numpy'"`
199+
Taking it all together,
200+
201+
```bash
202+
$ RUN=$(bx head -n 1 | awk 'NR==2 {print $4}')
203+
$ bx compare --run $RUN --profile variants --vary xp --baseline "'numpy'" --tables --all
204+
```
205+
206+
which first repeats the same information it gave without `--table`, and then emits
207+
the summary tables.
208+
209+
```text
210+
run compare-20261127T180714Z profile variants baseline 'numpy' contender 'torch'
211+
212+
IMPROVED (3)
213+
bench_matmul [n=50] wall-time effect -64.67% noise 1.85% rounds=5
214+
bench_matmul [n=100] wall-time effect -68.11% noise 1.35% rounds=5
215+
bench_matmul [n=200] wall-time effect -42.49% noise 2.05% rounds=5
216+
217+
NO CHANGE DETECTED (1)
218+
bench_matmul [n=10] wall-time effect -3.72% noise 3.69% rounds=5
219+
220+
For local/gonzales xp='numpy' (5 rounds):
221+
bench_matmul ok
222+
===== ============
223+
n
224+
----- ------------
225+
10 2.92±0.4μs
226+
50 18.1±4μs
227+
100 49.4±10μs
228+
200 160±30μs
229+
===== ============
230+
231+
For local/gonzales xp='torch' (5 rounds):
232+
bench_matmul ok
233+
===== ============
234+
n
235+
----- ------------
236+
10 2.80±0.2μs
237+
50 6.42±0.5μs
238+
100 16.1±2μs
239+
200 95.6±9μs
240+
===== ============
241+
242+
| Change | Before ['numpy'] | After ['torch'] | Ratio | Noise | Verdict | Benchmark (Parameter) |
243+
|----------|--------------------|-------------------|---------|---------|--------------------|-------------------------|
244+
| | 2.92±0.4μs | 2.80±0.2μs | 0.96 | 3.69% | no change detected | bench_matmul(10) |
245+
| - | 18.1±4μs | 6.42±0.5μs | 0.35 | 1.85% | improved | bench_matmul(50) |
246+
| - | 49.4±10μs | 16.1±2μs | 0.33 | 1.35% | improved | bench_matmul(100) |
247+
| - | 160±30μs | 95.6±9μs | 0.60 | 2.05% | improved | bench_matmul(200) |
248+
```
249+
250+
189251
## A manual loop + "run mode" comparisons.
190252

191253
Above we used `bx compare` in the so-called *measure mode*, where it ran the benchmarks under the comparison schedule. An alternative, more
192-
manual, way is to run a loop over `bx bench` calls and then invoke `bx compare` in the *run mode*, where it pulls the data from the store.
193-
We need to handle alternating the sides manually: Each call runs one library, with `--filter`, as one side of a session; we use
194-
`--round` and `--slot` to place it into the comparison sequence, and `bx compare --run` compares the sides:
254+
manual, way is to run a loop over `bx bench` calls and then invoke `bx compare` in the *run mode*, as before.
255+
256+
For the first step, we need to handle alternating the sides manually: Each call runs one library,
257+
with `--filter`, as one side of a session; we use `--round` and `--slot` to place it into the comparison sequence;
258+
we also need to specify the same run key for all calls, via the `--run-key` argument.
195259

196260
```
197261
for r in 0 1 2; do

0 commit comments

Comments
 (0)