Calliper is a Callgrind-based benchmarking harness with few-too-many knobs sticking out.
To use calliper, you must have Valgrind installed.
To write your first benchmark with calliper, add the following to your Cargo.toml
:
```toml
[dev-dependencies]
calliper = "0.0.1"
[[bench]] name = "myfirstcalliper_benchmark" harness = false ```
Then, create a file at $PROJECT/benches/my_first_calliper_benchmark.rs
with the following contents:
``` use calliper::{run, Scenario, ScenarioConfig};
fn fibonacci(n: u64) -> u64 { match n { 0 => 1, 1 => 1, n => fibonacci(n-1) + fibonacci(n-2), } }
fn shortbenchmark() -> u64 { fibonacci(blackbox(10)) }
fn longbenchmark() -> u64 { fibonacci(blackbox(30)) }
fn main() { let config = ScenarioConfig::default(); let benches = [Scenario::new(longbenchmark, config), Scenario::new(shortbenchmark, config)]; run(&benches).unwrap(); } ```
Now the benchmark can be executed with cargo bench
.
More sophisticated examples can be found in benches folder of this repository.
This project is licensed under either of
at your option.
Calliper is inspired by Iai benchmarking harness.