diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d7f39e49..168ce546 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,11 +16,11 @@ jobs: matrix: rust: - stable - - beta - - 1.57 # MSRV + - 1.59 # MSRV + - nightly steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 name: Setup rust toolchain @@ -30,7 +30,7 @@ jobs: override: true components: rustfmt, clippy - - uses: Swatinem/rust-cache@v1 + - uses: Swatinem/rust-cache@v2 name: Load dependencies from cache - uses: actions-rs/cargo@v1 @@ -73,6 +73,7 @@ jobs: - uses: actions-rs/cargo@v1 name: Check for clippy hints + if: ${{ matrix.rust == 'stable' }} with: command: clippy args: -- -D warnings diff --git a/src/analysis/mod.rs b/src/analysis/mod.rs index 23647c13..1851d718 100644 --- a/src/analysis/mod.rs +++ b/src/analysis/mod.rs @@ -222,7 +222,7 @@ pub(crate) fn common( }; let measurement_data = crate::report::MeasurementData { - data: Data::new(&*iters, &*times), + data: Data::new(&iters, ×), avg_times: labeled_sample, absolute_estimates: estimates, distributions, diff --git a/src/csv_report.rs b/src/csv_report.rs index 3b744df0..f8e2a05f 100644 --- a/src/csv_report.rs +++ b/src/csv_report.rs @@ -35,6 +35,7 @@ impl CsvReportWriter { let value = id.value_str.as_deref(); let (throughput_num, throughput_type) = match id.throughput { Some(Throughput::Bytes(bytes)) => (Some(format!("{}", bytes)), Some("bytes")), + Some(Throughput::BytesDecimal(bytes)) => (Some(format!("{}", bytes)), Some("bytes")), Some(Throughput::Elements(elems)) => (Some(format!("{}", elems)), Some("elements")), None => (None, None), }; diff --git a/src/html/mod.rs b/src/html/mod.rs index d3606562..0809aae3 100644 --- a/src/html/mod.rs +++ b/src/html/mod.rs @@ -438,7 +438,7 @@ impl Report for Html { // If all of the value strings can be parsed into a number, sort/dedupe // numerically. Otherwise sort lexicographically. - if value_strs.iter().all(|os| try_parse(*os).is_some()) { + if value_strs.iter().all(|os| try_parse(os).is_some()) { value_strs.sort_unstable_by(|v1, v2| { let num1 = try_parse(v1); let num2 = try_parse(v2); @@ -464,7 +464,7 @@ impl Report for Html { self.generate_summary( &subgroup_id, - &*samples_with_function, + &samples_with_function, context, formatter, false, @@ -483,13 +483,7 @@ impl Report for Html { let subgroup_id = BenchmarkId::new(group_id.clone(), None, Some(value_str.clone()), None); - self.generate_summary( - &subgroup_id, - &*samples_with_value, - context, - formatter, - false, - ); + self.generate_summary(&subgroup_id, &samples_with_value, context, formatter, false); } } @@ -516,7 +510,7 @@ impl Report for Html { self.generate_summary( &BenchmarkId::new(group_id, None, None, None), - &*(all_data), + &all_data, context, formatter, true, diff --git a/src/lib.rs b/src/lib.rs index 20e1eeaf..293fb431 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -104,10 +104,10 @@ pub use crate::bencher::Bencher; pub use crate::benchmark_group::{BenchmarkGroup, BenchmarkId}; static DEBUG_ENABLED: Lazy = Lazy::new(|| std::env::var_os("CRITERION_DEBUG").is_some()); -static GNUPLOT_VERSION: Lazy> = - Lazy::new(|| criterion_plot::version()); +static GNUPLOT_VERSION: Lazy> = Lazy::new(criterion_plot::version); static DEFAULT_PLOTTING_BACKEND: Lazy = Lazy::new(|| match &*GNUPLOT_VERSION { Ok(_) => PlottingBackend::Gnuplot, + #[cfg(feature = "plotters")] Err(e) => { match e { VersionError::Exec(_) => println!("Gnuplot not found, using plotters backend"), @@ -118,6 +118,8 @@ static DEFAULT_PLOTTING_BACKEND: Lazy = Lazy::new(|| match &*GN }; PlottingBackend::Plotters } + #[cfg(not(feature = "plotters"))] + Err(_) => PlottingBackend::None, }); static CARGO_CRITERION_CONNECTION: Lazy>> = Lazy::new(|| match std::env::var("CARGO_CRITERION_PORT") { @@ -357,7 +359,7 @@ fn cargo_target_directory() -> Option { .map(PathBuf::from) .or_else(|| { let output = Command::new(env::var_os("CARGO")?) - .args(&["metadata", "--format-version", "1"]) + .args(["metadata", "--format-version", "1"]) .output() .ok()?; let metadata: Metadata = serde_json::from_slice(&output.stdout).ok()?; @@ -732,7 +734,7 @@ impl Criterion { .long("color") .alias("colour") .takes_value(true) - .possible_values(&["auto", "always", "never"]) + .possible_values(["auto", "always", "never"]) .default_value("auto") .help("Configure coloring of output. always = always colorize output, never = never colorize output, auto = colorize output if output is a tty and compiled for unix.")) .arg(Arg::new("verbose") @@ -825,12 +827,12 @@ impl Criterion { .arg(Arg::new("plotting-backend") .long("plotting-backend") .takes_value(true) - .possible_values(&["gnuplot", "plotters"]) + .possible_values(["gnuplot", "plotters"]) .help("Set the plotting backend. By default, Criterion.rs will use the gnuplot backend if gnuplot is available, or the plotters backend if it isn't.")) .arg(Arg::new("output-format") .long("output-format") .takes_value(true) - .possible_values(&["criterion", "bencher"]) + .possible_values(["criterion", "bencher"]) .default_value("criterion") .help("Change the CLI output format. By default, Criterion.rs will use its own format. If output format is set to 'bencher', Criterion.rs will print output in a format that resembles the 'bencher' crate.")) .arg(Arg::new("nocapture") diff --git a/src/plot/gnuplot_backend/summary.rs b/src/plot/gnuplot_backend/summary.rs index d57a1749..529463b2 100644 --- a/src/plot/gnuplot_backend/summary.rs +++ b/src/plot/gnuplot_backend/summary.rs @@ -130,7 +130,7 @@ pub fn violin( ) -> Child { let path = PathBuf::from(&path); let all_curves_vec = all_curves.iter().rev().cloned().collect::>(); - let all_curves: &[&(&BenchmarkId, Vec)] = &*all_curves_vec; + let all_curves: &[&(&BenchmarkId, Vec)] = &all_curves_vec; let kdes = all_curves .iter() diff --git a/src/plot/plotters_backend/distributions.rs b/src/plot/plotters_backend/distributions.rs index 82f9eae5..8de11405 100644 --- a/src/plot/plotters_backend/distributions.rs +++ b/src/plot/plotters_backend/distributions.rs @@ -85,11 +85,11 @@ fn abs_distribution( chart .draw_series(LineSeries::new( kde_xs.iter().zip(ys.iter()).map(|(&x, &y)| (x, y)), - &DARK_BLUE, + DARK_BLUE, )) .unwrap() .label("Bootstrap distribution") - .legend(|(x, y)| PathElement::new(vec![(x, y), (x + 20, y)], &DARK_BLUE)); + .legend(|(x, y)| PathElement::new(vec![(x, y), (x + 20, y)], DARK_BLUE)); chart .draw_series(AreaSeries::new( @@ -115,7 +115,7 @@ fn abs_distribution( ))) .unwrap() .label("Point estimate") - .legend(|(x, y)| PathElement::new(vec![(x, y), (x + 20, y)], &DARK_BLUE)); + .legend(|(x, y)| PathElement::new(vec![(x, y), (x + 20, y)], DARK_BLUE)); chart .configure_series_labels() @@ -240,11 +240,11 @@ fn rel_distribution( chart .draw_series(LineSeries::new( xs.iter().zip(ys.iter()).map(|(x, y)| (*x, *y)), - &DARK_BLUE, + DARK_BLUE, )) .unwrap() .label("Bootstrap distribution") - .legend(|(x, y)| PathElement::new(vec![(x, y), (x + 20, y)], &DARK_BLUE)); + .legend(|(x, y)| PathElement::new(vec![(x, y), (x + 20, y)], DARK_BLUE)); chart .draw_series(AreaSeries::new( @@ -269,7 +269,7 @@ fn rel_distribution( ))) .unwrap() .label("Point estimate") - .legend(|(x, y)| PathElement::new(vec![(x, y), (x + 20, y)], &DARK_BLUE)); + .legend(|(x, y)| PathElement::new(vec![(x, y), (x + 20, y)], DARK_BLUE)); chart .draw_series(std::iter::once(Rectangle::new( diff --git a/src/plot/plotters_backend/iteration_times.rs b/src/plot/plotters_backend/iteration_times.rs index 4d0a22a9..3ac4f1cc 100644 --- a/src/plot/plotters_backend/iteration_times.rs +++ b/src/plot/plotters_backend/iteration_times.rs @@ -37,7 +37,7 @@ pub(crate) fn iteration_times_figure( .configure_mesh() .y_desc(format!("Average Iteration Time ({})", unit)) .x_label_formatter(&|x| pretty_print_float(*x, true)) - .light_line_style(&TRANSPARENT) + .light_line_style(TRANSPARENT) .draw() .unwrap(); @@ -104,7 +104,7 @@ pub(crate) fn iteration_times_comparison_figure( .configure_mesh() .y_desc(format!("Average Iteration Time ({})", unit)) .x_label_formatter(&|x| pretty_print_float(*x, true)) - .light_line_style(&TRANSPARENT) + .light_line_style(TRANSPARENT) .draw() .unwrap(); diff --git a/src/plot/plotters_backend/pdf.rs b/src/plot/plotters_backend/pdf.rs index 333893fc..957bb442 100644 --- a/src/plot/plotters_backend/pdf.rs +++ b/src/plot/plotters_backend/pdf.rs @@ -93,7 +93,7 @@ pub(crate) fn pdf_comparison_figure( ))) .unwrap() .label("Base Mean") - .legend(|(x, y)| PathElement::new(vec![(x, y), (x + 20, y)], &DARK_RED)); + .legend(|(x, y)| PathElement::new(vec![(x, y), (x + 20, y)], DARK_RED)); chart .draw_series(std::iter::once(PathElement::new( @@ -102,7 +102,7 @@ pub(crate) fn pdf_comparison_figure( ))) .unwrap() .label("New Mean") - .legend(|(x, y)| PathElement::new(vec![(x, y), (x + 20, y)], &DARK_BLUE)); + .legend(|(x, y)| PathElement::new(vec![(x, y), (x + 20, y)], DARK_BLUE)); if title.is_some() { chart.configure_series_labels().draw().unwrap(); @@ -255,18 +255,18 @@ pub(crate) fn pdf( chart .draw_series(std::iter::once(PathElement::new( vec![(mean, 0.0), (mean, max_iters)], - &DARK_BLUE, + DARK_BLUE, ))) .unwrap() .label("Mean") - .legend(|(x, y)| PathElement::new(vec![(x, y), (x + 20, y)], &DARK_BLUE)); + .legend(|(x, y)| PathElement::new(vec![(x, y), (x + 20, y)], DARK_BLUE)); chart .draw_series(vec![ - PathElement::new(vec![(lomt, 0.0), (lomt, max_iters)], &DARK_ORANGE), - PathElement::new(vec![(himt, 0.0), (himt, max_iters)], &DARK_ORANGE), - PathElement::new(vec![(lost, 0.0), (lost, max_iters)], &DARK_RED), - PathElement::new(vec![(hist, 0.0), (hist, max_iters)], &DARK_RED), + PathElement::new(vec![(lomt, 0.0), (lomt, max_iters)], DARK_ORANGE), + PathElement::new(vec![(himt, 0.0), (himt, max_iters)], DARK_ORANGE), + PathElement::new(vec![(lost, 0.0), (lost, max_iters)], DARK_RED), + PathElement::new(vec![(hist, 0.0), (hist, max_iters)], DARK_RED), ]) .unwrap(); use crate::stats::univariate::outliers::tukey::Label; diff --git a/src/plot/plotters_backend/regression.rs b/src/plot/plotters_backend/regression.rs index c944dbbe..1a9adece 100644 --- a/src/plot/plotters_backend/regression.rs +++ b/src/plot/plotters_backend/regression.rs @@ -61,7 +61,7 @@ pub(crate) fn regression_figure( .x_desc(x_label) .y_desc(format!("Total sample time ({})", unit)) .x_label_formatter(&|x| pretty_print_float(x * x_scale, true)) - .light_line_style(&TRANSPARENT) + .light_line_style(TRANSPARENT) .draw() .unwrap(); @@ -79,7 +79,7 @@ pub(crate) fn regression_figure( chart .draw_series(std::iter::once(PathElement::new( vec![(0.0, 0.0), (max_iters, point)], - &DARK_BLUE, + DARK_BLUE, ))) .unwrap() .label("Linear regression") @@ -187,13 +187,13 @@ pub(crate) fn regression_comparison_figure( .x_desc(x_label) .y_desc(format!("Total sample time ({})", unit)) .x_label_formatter(&|x| pretty_print_float(x * x_scale, true)) - .light_line_style(&TRANSPARENT) + .light_line_style(TRANSPARENT) .draw() .unwrap(); chart .draw_series(vec![ - PathElement::new(vec![(0.0, 0.0), (max_iters, base_point)], &DARK_RED).into_dyn(), + PathElement::new(vec![(0.0, 0.0), (max_iters, base_point)], DARK_RED).into_dyn(), Polygon::new( vec![(0.0, 0.0), (max_iters, base_lb), (max_iters, base_ub)], DARK_RED.mix(0.25).filled(), @@ -208,7 +208,7 @@ pub(crate) fn regression_comparison_figure( chart .draw_series(vec![ - PathElement::new(vec![(0.0, 0.0), (max_iters, point)], &DARK_BLUE).into_dyn(), + PathElement::new(vec![(0.0, 0.0), (max_iters, point)], DARK_BLUE).into_dyn(), Polygon::new( vec![(0.0, 0.0), (max_iters, lb), (max_iters, ub)], DARK_BLUE.mix(0.25).filled(), diff --git a/src/plot/plotters_backend/summary.rs b/src/plot/plotters_backend/summary.rs index a5a410d6..23f4053d 100644 --- a/src/plot/plotters_backend/summary.rs +++ b/src/plot/plotters_backend/summary.rs @@ -159,7 +159,7 @@ pub fn violin( axis_scale: AxisScale, ) { let all_curves_vec = all_curves.iter().rev().cloned().collect::>(); - let all_curves: &[&(&BenchmarkId, Vec)] = &*all_curves_vec; + let all_curves: &[&(&BenchmarkId, Vec)] = &all_curves_vec; let mut kdes = all_curves .iter() @@ -250,7 +250,7 @@ fn draw_violin_figure, YR: AsRangedCoord, YR: AsRangedCoord