CodSpeedHQ/codspeed-rust

Generic parameters on `Bencher` are not API compatible with criterion

davidhewitt opened this issue · 3 comments

In PyO3 we tend to manifest all lifetime parameters in structures, eg: https://github.com/PyO3/pyo3/blob/8dc3d2bc118bd03d206c666bf0ad1d304b737728/pyo3-benches/benches/bench_any.rs#L64

(So we write &mut Bencher<'_> instead of &mut Bencher.)

The compat mode of this crate doesn't have the lifetime parameter (or the generic parameter M: Measurement, but that's not relevant to us in PyO3).

I think for the lifetime it would be possible to solve this by changing the definition of Bencher to be

pub struct Bencher<'a> {
    codspeed: &'a mut CodSpeed,
    uri: String,
}
art049 commented

I didn't think about this while building the adapter but it makes complete sense. I'll work on it ASAP.

art049 commented

Just released it in 2.3.0, let me know if that works for you!

Thanks, yep I've merged the codspeed benchmarks into PyO3 this morning, look forward to seeing how it works out!