Skip to content

Commit

Permalink
feat!: remove all plotting related functionalities
Browse files Browse the repository at this point in the history
I don't need them, and they make everything too complicated
  • Loading branch information
Boshen committed Jun 1, 2024
1 parent 0ad7d78 commit fc1cb4e
Show file tree
Hide file tree
Showing 41 changed files with 9 additions and 7,223 deletions.
29 changes: 0 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ tokio = { version = "1.37", default-features = false, features = [
"rt",
], optional = true }
async-std = { version = "1.12", optional = true }
plotters = { version = "^0.3.5", default-features = false, features = [
"svg_backend",
"area_series",
"line_series",
], optional = true }
codspeed = { version = "2.6.0", optional = true }
colored = { version = "2.1.0", optional = true }

Expand All @@ -80,7 +75,7 @@ stable = [
"async_tokio",
"async_std",
]
default = ["rayon", "plotters", "cargo_bench_support"]
default = ["rayon", "cargo_bench_support"]

## Enables [codspeed](https://codspeed.io)
codspeed = ["dep:codspeed", "dep:colored"]
Expand Down
11 changes: 1 addition & 10 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{report::CliVerbosity, BenchmarkConfig, ListFormat, PlottingBackend};
use crate::{report::CliVerbosity, BenchmarkConfig, ListFormat};
use bpaf::*;
use std::{str::FromStr, time::Duration};

Expand All @@ -20,7 +20,6 @@ pub struct Opts {
pub noise_threshold: f64,
pub confidence_level: f64,
pub significance_level: f64,
pub plotting_backend: Option<PlottingBackend>,
pub output_format: OutputFormat,

// ignored
Expand Down Expand Up @@ -274,13 +273,6 @@ pub fn options(config: &BenchmarkConfig) -> OptionParser<Opts> {
.help("Ignored, but added for compatibility with libsets.")
.switch()
.hide();
let plotting_backend = long("plotting-backend")
.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.",
)
.argument("PLOT")
.optional();

let output_format =
long("output-format")
Expand All @@ -294,7 +286,6 @@ pub fn options(config: &BenchmarkConfig) -> OptionParser<Opts> {
warm_up_time, measurement_time,
nresamples, noise_threshold, confidence_level, significance_level,
nocapture, show_output, include_ignored,
plotting_backend,
output_format,
ignored, exact, filter})
.to_options()
Expand Down
66 changes: 4 additions & 62 deletions src/criterion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use std::time::Duration;
use crate::bencher::Bencher;
use crate::benchmark_group::{BenchmarkGroup, BenchmarkId};
use crate::{
cargo_criterion_connection, debug_enabled, default_output_directory, default_plotting_backend,
gnuplot_version, Baseline, BencherReport, BenchmarkConfig, BenchmarkFilter, CliReport,
CliVerbosity, Connection, ExternalProfiler, Html, Measurement, Mode, OutgoingMessage,
PlotConfiguration, PlottingBackend, Profiler, Report, ReportContext, Reports, WallTime,
cargo_criterion_connection, debug_enabled, default_output_directory, Baseline, BencherReport,
BenchmarkConfig, BenchmarkFilter, CliReport, CliVerbosity, Connection, ExternalProfiler,
Measurement, Mode, OutgoingMessage, PlotConfiguration, Profiler, Report, ReportContext,
Reports, WallTime,
};

/// The benchmark manager
Expand Down Expand Up @@ -62,7 +62,6 @@ impl Default for Criterion {
cli: CliReport::new(false, false, CliVerbosity::Normal),
bencher_enabled: false,
bencher: BencherReport,
html: default_plotting_backend().create_plotter().map(Html::new),
csv_enabled: cfg!(feature = "csv_output"),
};

Expand All @@ -87,7 +86,6 @@ impl Default for Criterion {
criterion.report.cli_enabled = false;
criterion.report.bencher_enabled = false;
criterion.report.csv_enabled = false;
criterion.report.html = None;
}
criterion
}
Expand Down Expand Up @@ -122,25 +120,6 @@ impl<M: Measurement> Criterion<M> {
Criterion { profiler: Box::new(RefCell::new(p)), ..self }
}

#[must_use]
/// Set the plotting backend. By default, Criterion will use gnuplot if available, or plotters
/// if not.
///
/// Panics if `backend` is `PlottingBackend::Gnuplot` and gnuplot is not available.
pub fn plotting_backend(mut self, backend: PlottingBackend) -> Criterion<M> {
if let PlottingBackend::Gnuplot = backend {
assert!(
!gnuplot_version().is_err(),
"Gnuplot plotting backend was requested, but gnuplot is not available. \
To continue, either install Gnuplot or allow Criterion.rs to fall back \
to using plotters."
);
}

self.report.html = backend.create_plotter().map(Html::new);
self
}

#[must_use]
/// Changes the default size of the sample for benchmarks run with this runner.
///
Expand Down Expand Up @@ -279,28 +258,6 @@ impl<M: Measurement> Criterion<M> {
self
}

#[must_use]
/// Enables plotting
pub fn with_plots(mut self) -> Criterion<M> {
// If running under cargo-criterion then don't re-enable the reports; let it do the reporting.
if self.connection.is_none() && self.report.html.is_none() {
let default_backend = default_plotting_backend().create_plotter();
if let Some(backend) = default_backend {
self.report.html = Some(Html::new(backend));
} else {
panic!("Cannot find a default plotting backend!");
}
}
self
}

#[must_use]
/// Disables plotting
pub fn without_plots(mut self) -> Criterion<M> {
self.report.html = None;
self
}

#[must_use]
/// Names an explicit baseline and enables overwriting the previous results.
pub fn save_baseline(mut self, baseline: String) -> Criterion<M> {
Expand Down Expand Up @@ -387,12 +344,6 @@ impl<M: Measurement> Criterion<M> {
if opts.verbosity == CliVerbosity::Verbose {
eprintln!("Warning: --verbose will be ignored when running with cargo-criterion. Use `cargo criterion --output-format verbose -- <args>` instead.");
}
if opts.noplot {
eprintln!("Warning: --noplot will be ignored when running with cargo-criterion. Use `cargo criterion --plotting-backend disabled -- <args>` instead.");
}
if let Some(backend) = opts.plotting_backend {
eprintln!("Warning: --plotting-backend will be ignored when running with cargo-criterion. Use `cargo criterion --plotting-backend {} -- <args>` instead.", backend);
}
if opts.output_format != OutputFormat::Criterion {
eprintln!("Warning: --output-format will be ignored when running with cargo-criterion. Use `cargo criterion --output-format {} -- <args>` instead.", opts.output_format);
}
Expand Down Expand Up @@ -432,14 +383,6 @@ impl<M: Measurement> Criterion<M> {
};
self = self.with_benchmark_filter(filter);

if let Some(backend) = opts.plotting_backend {
self = self.plotting_backend(backend)
};

if opts.noplot {
self = self.without_plots();
}

match opts.baseline {
Baseline_::Save(ref dir) => {
self.baseline = Baseline::Save;
Expand All @@ -463,7 +406,6 @@ impl<M: Measurement> Criterion<M> {
self.report.cli_enabled = false;
self.report.bencher_enabled = false;
self.report.csv_enabled = false;
self.report.html = None;
} else {
match opts.output_format {
OutputFormat::Bencher => {
Expand Down
Loading

0 comments on commit fc1cb4e

Please sign in to comment.