CodSpeedHQ / codspeed-rust

Rust crates to create CodSpeed benchmarks
https://codspeed.io
Apache License 2.0
23 stars 9 forks source link

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

Closed davidhewitt closed 1 year ago

davidhewitt commented 1 year ago

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 1 year ago

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

art049 commented 1 year ago

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

davidhewitt commented 1 year ago

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