Skip to content

Commit

Permalink
feat!: remove csv_output (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen authored Jun 11, 2024
1 parent d0cbf12 commit 7d31867
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 176 deletions.
22 changes: 0 additions & 22 deletions Cargo.lock

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

8 changes: 1 addition & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ oorandom = "11.1.3"

# Optional dependencies
rayon = { version = "1.10", optional = true }
csv = { version = "1.3", optional = true }
futures = { version = "0.3.30", default-features = false, optional = true }
smol = { version = "2.0", default-features = false, optional = true }
tokio = { version = "1.38.0", default-features = false, features = ["rt"], optional = true }
Expand All @@ -58,7 +57,7 @@ futures = { version = "0.3.30", default-features = false, features = ["execut
[features]
default = ["cargo_bench_support", "rayon"]

stable = ["async_futures", "async_smol", "async_std", "async_tokio", "csv_output"]
stable = ["async_futures", "async_smol", "async_std", "async_tokio"]

## Enables [codspeed](https://codspeed.io)
codspeed = ["dep:codspeed", "dep:colored"]
Expand All @@ -79,11 +78,6 @@ async_std = ["async", "async-std"]
# required in order to have Criterion.rs be usable outside of cargo-criterion.
cargo_bench_support = []

# This feature _currently_ does nothing, but in 0.4.0 it will be
# required in order to have Criterion.rs generate CSV files. This feature is deprecated in favor of
# cargo-criterion's --message-format=json option.
csv_output = ["csv"]

# Enable all of the async runtimes for the docs.rs output
[package.metadata.docs.rs]
features = ["async_futures", "async_smol", "async_std", "async_tokio"]
2 changes: 0 additions & 2 deletions src/analysis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,4 @@ fn copy_new_dir_to_base(id: &str, baseline: &str, output_directory: &Path) {
try_else_return!(fs::cp(&new_dir.join("sample.json"), &base_dir.join("sample.json")));
try_else_return!(fs::cp(&new_dir.join("tukey.json"), &base_dir.join("tukey.json")));
try_else_return!(fs::cp(&new_dir.join("benchmark.json"), &base_dir.join("benchmark.json")));
#[cfg(feature = "csv_output")]
try_else_return!(fs::cp(&new_dir.join("raw.csv"), &base_dir.join("raw.csv")));
}
3 changes: 0 additions & 3 deletions src/criterion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ impl Default for Criterion {
cli: CliReport::new(false, false, CliVerbosity::Normal),
bencher_enabled: false,
bencher: BencherReport,
csv_enabled: cfg!(feature = "csv_output"),
};

let mut criterion = Criterion {
Expand All @@ -86,7 +85,6 @@ impl Default for Criterion {
// disable all reports when connected to cargo-criterion; it will do the reporting.
criterion.report.cli_enabled = false;
criterion.report.bencher_enabled = false;
criterion.report.csv_enabled = false;
}
criterion
}
Expand Down Expand Up @@ -411,7 +409,6 @@ impl<M: Measurement> Criterion<M> {
// disable all reports when connected to cargo-criterion; it will do the reporting.
self.report.cli_enabled = false;
self.report.bencher_enabled = false;
self.report.csv_enabled = false;
} else {
match opts.output_format {
OutputFormat::Bencher => {
Expand Down
95 changes: 0 additions & 95 deletions src/csv_report.rs

This file was deleted.

34 changes: 3 additions & 31 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
use std::{error::Error as StdError, fmt, io, path::PathBuf};

#[cfg(feature = "csv_output")]
use csv::Error as CsvError;
use serde_json::Error as SerdeError;

#[allow(clippy::enum_variant_names)]
#[derive(Debug)]
pub enum Error {
AccessError {
path: PathBuf,
inner: io::Error,
},
CopyError {
from: PathBuf,
to: PathBuf,
inner: io::Error,
},
SerdeError {
path: PathBuf,
inner: SerdeError,
},
#[cfg(feature = "csv_output")]
/// This API requires the following crate features to be activated: csv_output
CsvError(CsvError),
AccessError { path: PathBuf, inner: io::Error },
CopyError { from: PathBuf, to: PathBuf, inner: io::Error },
SerdeError { path: PathBuf, inner: SerdeError },
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand All @@ -38,8 +23,6 @@ impl fmt::Display for Error {
"Failed to read or write file {:?} due to serialization error: {}",
path, inner
),
#[cfg(feature = "csv_output")]
Error::CsvError(inner) => write!(f, "CSV error: {}", inner),
}
}
}
Expand All @@ -49,8 +32,6 @@ impl StdError for Error {
Error::AccessError { .. } => "AccessError",
Error::CopyError { .. } => "CopyError",
Error::SerdeError { .. } => "SerdeError",
#[cfg(feature = "csv_output")]
Error::CsvError(_) => "CsvError",
}
}

Expand All @@ -59,19 +40,10 @@ impl StdError for Error {
Error::AccessError { inner, .. } => Some(inner),
Error::CopyError { inner, .. } => Some(inner),
Error::SerdeError { inner, .. } => Some(inner),
#[cfg(feature = "csv_output")]
Error::CsvError(inner) => Some(inner),
}
}
}

#[cfg(feature = "csv_output")]
impl From<CsvError> for Error {
fn from(other: CsvError) -> Error {
Error::CsvError(other)
}
}

pub type Result<T> = ::std::result::Result<T, Error>;

pub(crate) fn log_error(e: &Error) {
Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ mod bencher;
mod cli;
mod connection;
mod criterion;
#[cfg(feature = "csv_output")]
mod csv_report;
mod error;
mod estimate;
mod format;
Expand Down
12 changes: 0 additions & 12 deletions src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ use std::{
use anes::{Attribute, ClearLine, Color, ResetAttributes, SetAttribute, SetForegroundColor};
use serde::{Deserialize, Serialize};

#[cfg(feature = "csv_output")]
use crate::csv_report::FileCsvReport;
use crate::{
estimate::{ChangeDistributions, ChangeEstimates, Distributions, Estimate, Estimates},
format,
Expand Down Expand Up @@ -52,11 +50,6 @@ impl<'a> MeasurementData<'a> {
pub fn iter_counts(&self) -> &Sample<f64> {
self.data.x()
}

#[cfg(feature = "csv_output")]
pub fn sample_times(&self) -> &Sample<f64> {
self.data.y()
}
}

#[derive(Debug, Clone, Copy, Eq, PartialEq)]
Expand Down Expand Up @@ -295,7 +288,6 @@ pub(crate) struct Reports {
pub(crate) cli: CliReport,
pub(crate) bencher_enabled: bool,
pub(crate) bencher: BencherReport,
pub(crate) csv_enabled: bool,
}
macro_rules! reports_impl {
(fn $name:ident(&self, $($argn:ident: $argt:ty),*)) => {
Expand All @@ -306,10 +298,6 @@ macro_rules! reports_impl {
if self.bencher_enabled {
self.bencher.$name($($argn),*);
}
#[cfg(feature = "csv_output")]
if self.csv_enabled {
FileCsvReport.$name($($argn),*);
}
}
};
}
Expand Down
2 changes: 0 additions & 2 deletions tests/criterion_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ fn verify_stats(dir: &Path, baseline: &str) {
verify_json(dir, &format!("{}/sample.json", baseline));
verify_json(dir, &format!("{}/tukey.json", baseline));
verify_json(dir, &format!("{}/benchmark.json", baseline));
#[cfg(feature = "csv_output")]
verify_file(dir, &format!("{}/raw.csv", baseline));
}

fn verify_not_exists(dir: &Path, path: &str) {
Expand Down

0 comments on commit 7d31867

Please sign in to comment.