Expand description
Count values processed in each iteration to measure throughput.
Examples
The following example measures throughput of converting
&[i32]
into Vec<i32>
by providing BytesCount
via Bencher::counter
:
use divan::counter::BytesCount;
#[divan::bench]
fn slice_into_vec(bencher: divan::Bencher) {
let ints: &[i32] = &[
// ...
];
let bytes = BytesCount::of_slice(ints);
bencher
.counter(bytes)
.bench(|| -> Vec<i32> {
divan::black_box(ints).into()
});
}
Structs
- Process N bytes.
- Process N
char
s. - Process N items.
Enums
- The numerical base for
BytesCount
in benchmark outputs.
Traits
- Counts the number of values processed in each iteration of a benchmarked function.
- Conversion into a
Counter
.