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

Perform multiple Measurements at the same time

Open oberien opened this issue 4 years ago • 1 comments

Currently, I've only found ways to perform a single measurement at the same time. However, I'd like to measure both the cpu cycles (rdtscp) and time (CLOCK_THREAD_CPUTIME_ID) at the same time. I could have two benchmarks, one with cycles and one with time, but I don't want to run the benchmarks twice as they already take in the range of 10 minutes.

I tried implementing a custom Measurement, which uses a tuple of (cycles, time) as Value. However, it appears that the measurement value will be converted to an f64 for internal analysis and is pass to the ValueFormatter as an f64 as well.

I could think of the following two solutions:

  • Let the formatter format the output by passing the original Measurement::Value types.
  • Add a function Criterion::with_measurements(&[&dyn Measurement]), which allows performing multiple measurements during a single run.

oberien avatar Nov 25 '19 15:11 oberien

Hey, thanks for trying Criterion.rs and thanks for the suggestion!

This was deliberately left out of the custom-measurement implementation. Measuring multiple things at once raised too many follow-on changes to other parts of the code. I'd need to change a bunch of types through the rest of the code, there would need to be separate sections in the reports for each measurement, CSV and JSON files would have to be modified, etc. etc. To be clear, I would still like to do it, but it will take a bunch of work so it probably won't happen any time soon - I haven't had much time to work on Criterion.rs lately.

bheisler avatar Nov 30 '19 17:11 bheisler