1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*!### Benchmark harness with few too many knobs sticking out
Calliper is a library for benchmarking with
[Callgrind](https://valgrind.org/docs/manual/cl-manual.html), a call-graph and cache prediction
profiler. It aims to serve both upcoming and present benchmarking gurus.
Whenever possible, terminology/naming of Calliper aligns with that of Callgrind (in i.e.
parameter names).
# Example
```rust
use calliper::utils::black_box;
use calliper::{Runner, Scenario};
#[inline(never)]
#[no_mangle]
fn binary_search_impl(haystack: &[u8], needle: u8) -> Result<usize, usize> {
haystack.binary_search(&needle)
}
fn bench_binary_search() {
let range = (0..255).collect::<Vec<_>>();
let _ = black_box(binary_search_impl(black_box(&range), black_box(253)));
}
#[inline(never)]
#[no_mangle]
fn linear_search_impl(haystack: &[u8], needle: u8) -> Option<usize> {
haystack.iter().position(|n| *n == needle)
}
fn bench_linear_search() {
let range = (0..255).collect::<Vec<_>>();
black_box(linear_search_impl(black_box(&range), black_box(253)));
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let runner = Runner::default();
let benches = [
Scenario::new(bench_linear_search),
Scenario::new(bench_binary_search),
];
runner.run(&benches).unwrap();
Ok(())
}
```
Calliper basically respawns self process with modified environment variable that is used by [Runner] to determine which function to run (while already running under Callgrind).
*/
pub use ;
pub use CalliperError;
pub use ParsedCallgrindOutput;
pub use ;
pub use Scenario;
pub use ClientRequest;