Suggest a simpler incantation to isolate benchmarks

This commit is contained in:
Bodigrim 2023-02-11 01:23:07 +00:00
parent c9805fc653
commit 516eba6f1a
2 changed files with 8 additions and 22 deletions

View File

@ -387,22 +387,14 @@ main = defaultMain
Finally, as an ultimate measure to reduce interference between benchmarks,
one can run each of them in a separate process. We do not quite recommend
this approach, but if you are desperate, here is how.
Assuming that a benchmark is declared in `cabal` file as `benchmark my-bench` component,
let's first find its executable:
this approach, but if you are desperate, here is how:
```sh
cabal build --enable-benchmarks my-bench
MYBENCH=$(cabal list-bin my-bench) # available since cabal-3.4
cabal run -v0 all:benches -- -l | sed -e 's/[\"]/\\\\\\&/g' | while read -r name; do cabal run -v0 all:benches -- -p '$0 == "'"$name"'"'; done
```
Now list all benchmark names (hopefully, they do not contain newlines),
escape quotes and slashes, and run each of them separately:
```sh
$MYBENCH -l | sed -e 's/[\"]/\\\\\\&/g' | while read -r name; do $MYBENCH -p '$0 == "'"$name"'"'; done
```
This assumes that there is a single benchmark suite in the project
and that benchmark names do not contain newlines.
## Comparison against baseline

View File

@ -351,18 +351,12 @@ use
Finally, as an ultimate measure to reduce interference between
benchmarks, one can run each of them in a separate process. We do not
quite recommend this approach, but if you are desperate, here is how.
quite recommend this approach, but if you are desperate, here is how:
Assuming that a benchmark is declared in @cabal@ file as
@benchmark@ @my-bench@ component, lets first find its executable:
> cabal run -v0 all:benches -- -l | sed -e 's/[\"]/\\\\\\&/g' | while read -r name; do cabal run -v0 all:benches -- -p '$0 == "'"$name"'"'; done
> cabal build --enable-benchmarks my-bench
> MYBENCH=$(cabal list-bin my-bench) # available since cabal-3.4
Now list all benchmark names (hopefully, they do not contain newlines),
escape quotes and slashes, and run each of them separately:
> $MYBENCH -l | sed -e 's/[\"]/\\\\\\&/g' | while read -r name; do $MYBENCH -p '$0 == "'"$name"'"'; done
This assumes that there is a single benchmark suite in the project
and that benchmark names do not contain newlines.
=== Comparison against baseline