-
Notifications
You must be signed in to change notification settings - Fork 355
Open
Description
Taking #467 as a starting point, I wanted to have plots and removed .without_plots() option. I also updated to return iters * 42 instead of directly custom value.
This is returning the following error:
Compiling benches v0.1.0 (s)
Finished `bench` profile [optimized] target(s) in 0.86s
Running benches/repro.rs (target/release/deps/repro-fcb679e095c2c534)
Gnuplot not found, using plotters backend
repro time: [42 x 42 x 42 x]
change: [+0.0000% +0.0000% +0.0000%] (p = NaN > 0.05)
No change in performance detected.
thread 'main' panicked at /Users/gustavo/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/criterion-0.7.0/src/stats/univariate/sample.rs:31:9:
assertion failed: slice.len() > 1 && slice.iter().all(|x| !x.is_nan())
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: bench failed, to rerun pass `-p benches --bench repro`
Here is is the code:
use std::time::Duration;
use criterion::{
criterion_group, criterion_main,
measurement::{Measurement, ValueFormatter},
Criterion, Throughput,
};
fn repro(c: &mut Criterion<MyMeasurement>) {
c.bench_function("repro", |b| b.iter_custom(|iters| 42 * iters));
}
struct MyMeasurement;
impl Measurement for MyMeasurement {
type Intermediate = u64;
type Value = u64;
fn start(&self) -> Self::Intermediate {
return 0;
}
fn end(&self, i: Self::Intermediate) -> Self::Value {
return i;
}
fn add(&self, v1: &Self::Value, v2: &Self::Value) -> Self::Value {
return *v1 + *v2;
}
fn zero(&self) -> Self::Value {
return 0;
}
fn to_f64(&self, value: &Self::Value) -> f64 {
return *value as f64;
}
fn formatter(&self) -> &dyn ValueFormatter {
return &MyMeasurementFormatter;
}
}
struct MyMeasurementFormatter;
impl ValueFormatter for MyMeasurementFormatter {
fn scale_values(&self, _: f64, round: &mut [f64]) -> &'static str {
round[0] = round[0] as u64 as f64;
"x"
}
fn scale_throughputs(&self, _: f64, _throughput: &Throughput, _: &mut [f64]) -> &'static str {
panic!("unsupported")
}
fn scale_for_machines(&self, _: &mut [f64]) -> &'static str {
"x"
}
}
fn alt_measurement() -> Criterion<MyMeasurement> {
return Criterion::default()
.with_measurement(MyMeasurement)
.warm_up_time(Duration::from_nanos(1));
}
criterion_group! {
name = benches;
config = alt_measurement();
targets = repro,
}
criterion_main!(benches);Criterion version: 0.7.0
Rust version: 1.90 stable
Metadata
Metadata
Assignees
Labels
No labels