criterion.rs
criterion.rs copied to clipboard
Calculate throughput in MB/s or GB/s instead of MiB/s or GiB/s
I'm using Criterion with throughput calculation and it'd be really useful, but unfortunately thus far all data that we have reported was in GB/s, as in one billion bytes. Criterion gives results in GiB/s, so 2^30 bytes. I can't see a way to convert that, so either it's not there or it's not well documented.
A workaround for now is to configure it as elements and get reports of Gelems/s, it'd be nice to maybe change the label? So I could just say that instead of reporting "elems" report "Bs"?
You can implement your own Measurement
and return a custom ValueFormatter
and make it format differently.
You can wrap this inside a separate crate like the CyclesPerByte
Measurement.
I've implemented and then turned @ambiso workaround into a crate, so it can be reused: https://crates.io/crates/criterion-decimal-throughput
Hello! Thanks for the suggestion, and for the patience.
Yeah, that's a fair point. It will need to be in a breaking-change release, but I'd be open to including a Throughput::BytesDecimal
or similar.
@bheisler If you want help, I can do a PR with what I've implemented in https://github.com/V0ldek/criterion-decimal-throughput
A pull request (to the version 0.4 branch) would be welcome, yes!