Module divan::counter

source ·
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

Enums

Traits

  • Counts the number of values processed in each iteration of a benchmarked function.
  • Conversion into a Counter.