Open Swatinem opened 7 months ago
FWIW this is pretty standard for all Rust benchmarking using a custom harness (e.g. Criterion has the same requirement).
Here's my suggestion for running Divan outside of the benchmark harness:
fn main() {
divan::Divan::from_args().run_benches();
}
Running the benchmarks using
cargo bench
works just fine as expected. It also prints the typical cargoRunning benches/functions.rs (target/release/deps/functions-4227941eb3ee4115)
line.However running that target directly only lists the included benchmarks, it does not run them. This is a bit confusing if you want to run the benchmark directly in a profiler like
samply
.Actually running the benchmarks needs the
--bench
flag:https://github.com/nvzqz/divan/blob/0ff85855fd3aeacb2f24aa82ad90eb3efc93f060/src/divan.rs#L367-L376
However that flag is not documented at all in the command line flags:
https://github.com/nvzqz/divan/blob/0ff85855fd3aeacb2f24aa82ad90eb3efc93f060/src/cli.rs#L128-L129
It would be nice to actually document that flag, and maybe even provide an example how to run the benchmarks in a profiler like
samply
, which for me is as simple as runningsamply record target/release/deps/functions-4227941eb3ee4115 --bench