Skip to content

Commit

Permalink
Merge branch 'master' into replace-atty-with-is-terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
lemmih committed Dec 6, 2022
2 parents ed428f3 + 96c5fa1 commit 86e27bd
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 48 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/ci.yaml
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/mod.rs
Expand Up @@ -222,7 +222,7 @@ pub(crate) fn common<M: Measurement, T: ?Sized>(
};

let measurement_data = crate::report::MeasurementData {
data: Data::new(&*iters, &*times),
data: Data::new(&iters, &times),
avg_times: labeled_sample,
absolute_estimates: estimates,
distributions,
Expand Down
1 change: 1 addition & 0 deletions src/csv_report.rs
Expand Up @@ -35,6 +35,7 @@ impl<W: Write> CsvReportWriter<W> {
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),
};
Expand Down
14 changes: 4 additions & 10 deletions src/html/mod.rs
Expand Up @@ -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);
Expand All @@ -464,7 +464,7 @@ impl Report for Html {

self.generate_summary(
&subgroup_id,
&*samples_with_function,
&samples_with_function,
context,
formatter,
false,
Expand All @@ -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);
}
}

Expand All @@ -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,
Expand Down
14 changes: 8 additions & 6 deletions src/lib.rs
Expand Up @@ -104,10 +104,10 @@ pub use crate::bencher::Bencher;
pub use crate::benchmark_group::{BenchmarkGroup, BenchmarkId};

static DEBUG_ENABLED: Lazy<bool> = Lazy::new(|| std::env::var_os("CRITERION_DEBUG").is_some());
static GNUPLOT_VERSION: Lazy<Result<Version, VersionError>> =
Lazy::new(|| criterion_plot::version());
static GNUPLOT_VERSION: Lazy<Result<Version, VersionError>> = Lazy::new(criterion_plot::version);
static DEFAULT_PLOTTING_BACKEND: Lazy<PlottingBackend> = Lazy::new(|| match &*GNUPLOT_VERSION {
Ok(_) => PlottingBackend::Gnuplot,
#[cfg(feature = "plotters")]
Err(e) => {
match e {
VersionError::Exec(_) => println!("Gnuplot not found, using plotters backend"),
Expand All @@ -118,6 +118,8 @@ static DEFAULT_PLOTTING_BACKEND: Lazy<PlottingBackend> = Lazy::new(|| match &*GN
};
PlottingBackend::Plotters
}
#[cfg(not(feature = "plotters"))]
Err(_) => PlottingBackend::None,
});
static CARGO_CRITERION_CONNECTION: Lazy<Option<Mutex<Connection>>> =
Lazy::new(|| match std::env::var("CARGO_CRITERION_PORT") {
Expand Down Expand Up @@ -357,7 +359,7 @@ fn cargo_target_directory() -> Option<PathBuf> {
.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()?;
Expand Down Expand Up @@ -732,7 +734,7 @@ impl<M: Measurement> Criterion<M> {
.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")
Expand Down Expand Up @@ -825,12 +827,12 @@ impl<M: Measurement> Criterion<M> {
.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")
Expand Down
2 changes: 1 addition & 1 deletion src/plot/gnuplot_backend/summary.rs
Expand Up @@ -130,7 +130,7 @@ pub fn violin(
) -> Child {
let path = PathBuf::from(&path);
let all_curves_vec = all_curves.iter().rev().cloned().collect::<Vec<_>>();
let all_curves: &[&(&BenchmarkId, Vec<f64>)] = &*all_curves_vec;
let all_curves: &[&(&BenchmarkId, Vec<f64>)] = &all_curves_vec;

let kdes = all_curves
.iter()
Expand Down
12 changes: 6 additions & 6 deletions src/plot/plotters_backend/distributions.rs
Expand Up @@ -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(
Expand All @@ -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()
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/plot/plotters_backend/iteration_times.rs
Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down
16 changes: 8 additions & 8 deletions src/plot/plotters_backend/pdf.rs
Expand Up @@ -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(
Expand All @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions src/plot/plotters_backend/regression.rs
Expand Up @@ -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();

Expand All @@ -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")
Expand Down Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down
6 changes: 3 additions & 3 deletions src/plot/plotters_backend/summary.rs
Expand Up @@ -159,7 +159,7 @@ pub fn violin(
axis_scale: AxisScale,
) {
let all_curves_vec = all_curves.iter().rev().cloned().collect::<Vec<_>>();
let all_curves: &[&(&BenchmarkId, Vec<f64>)] = &*all_curves_vec;
let all_curves: &[&(&BenchmarkId, Vec<f64>)] = &all_curves_vec;

let mut kdes = all_curves
.iter()
Expand Down Expand Up @@ -250,15 +250,15 @@ fn draw_violin_figure<XR: AsRangedCoord<Value = f64>, YR: AsRangedCoord<Value =
.draw_series(AreaSeries::new(
x.iter().zip(y.iter()).map(|(x, y)| (*x, base + *y / 2.0)),
base,
&DARK_BLUE,
DARK_BLUE,
))
.unwrap();

chart
.draw_series(AreaSeries::new(
x.iter().zip(y.iter()).map(|(x, y)| (*x, base - *y / 2.0)),
base,
&DARK_BLUE,
DARK_BLUE,
))
.unwrap();
}
Expand Down
4 changes: 2 additions & 2 deletions src/plot/plotters_backend/t_test.rs
Expand Up @@ -38,7 +38,7 @@ pub(crate) fn t_test(
.draw_series(AreaSeries::new(
xs.iter().zip(ys.iter()).map(|(x, y)| (*x, *y)),
0.0,
&DARK_BLUE.mix(0.25),
DARK_BLUE.mix(0.25),
))
.unwrap()
.label("t distribution")
Expand All @@ -53,7 +53,7 @@ pub(crate) fn t_test(
)))
.unwrap()
.label("t statistic")
.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().draw().unwrap();
}

0 comments on commit 86e27bd

Please sign in to comment.