criterion.rs icon indicating copy to clipboard operation
criterion.rs copied to clipboard

Calculate throughput in MB/s or GB/s instead of MiB/s or GiB/s

Open V0ldek opened this issue 2 years ago • 2 comments

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"?

V0ldek avatar May 29 '22 14:05 V0ldek

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.

ambiso avatar Jun 03 '22 09:06 ambiso

I've implemented and then turned @ambiso workaround into a crate, so it can be reused: https://crates.io/crates/criterion-decimal-throughput

V0ldek avatar Jul 23 '22 22:07 V0ldek

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 avatar Aug 16 '22 22:08 bheisler

@bheisler If you want help, I can do a PR with what I've implemented in https://github.com/V0ldek/criterion-decimal-throughput

V0ldek avatar Aug 17 '22 08:08 V0ldek

A pull request (to the version 0.4 branch) would be welcome, yes!

bheisler avatar Aug 17 '22 19:08 bheisler