Skip to content

Commit

Permalink
Move quantity module
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed Jan 4, 2025
1 parent d869e8a commit 3cdae0f
Show file tree
Hide file tree
Showing 16 changed files with 20 additions and 19 deletions.
3 changes: 2 additions & 1 deletion src/benchmark/benchmark_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use std::collections::BTreeMap;

use serde::Serialize;

use crate::benchmark::{measurement::Measurements, quantity::Time};
use crate::benchmark::measurement::Measurements;
use crate::quantity::Time;

/// Parameter value and whether it was used in the command line template
#[derive(Debug, Default, Clone, Serialize, PartialEq)]
Expand Down
6 changes: 3 additions & 3 deletions src/benchmark/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use std::process::ExitStatus;

use crate::benchmark::measurement::Measurement;
use crate::benchmark::measurement::Measurements;
use crate::benchmark::quantity::Information;
use crate::benchmark::quantity::InformationQuantity;
use crate::benchmark::quantity::{Time, TimeQuantity};
use crate::command::Command;
use crate::options::{
CmdFailureAction, CommandInputPolicy, CommandOutputPolicy, Options, OutputStyleOption, Shell,
};
use crate::output::progress_bar::get_progress_bar;
use crate::quantity::Information;
use crate::quantity::InformationQuantity;
use crate::quantity::{Time, TimeQuantity};
use crate::timer::execute_and_measure;
use crate::util::randomized_environment_offset;

Expand Down
4 changes: 2 additions & 2 deletions src/benchmark/measurement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use std::process::ExitStatus;

use serde::Serialize;

use crate::benchmark::quantity::{
use crate::outlier_detection::modified_zscores;
use crate::quantity::{
max, mean, median, min, second, serialize_information, serialize_time, standard_deviation,
Information, Time, TimeQuantity,
};
use crate::outlier_detection::modified_zscores;
use crate::util::exit_code::extract_exit_code;

fn serialize_exit_status<S>(exit_status: &ExitStatus, serializer: S) -> Result<S::Ok, S::Error>
Expand Down
3 changes: 1 addition & 2 deletions src/benchmark/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pub mod benchmark_result;
pub mod executor;
pub mod measurement;
pub mod quantity;
pub mod relative_speed;
pub mod scheduler;

Expand All @@ -10,7 +9,6 @@ use std::cmp;
use crate::benchmark::benchmark_result::Parameter;
use crate::benchmark::executor::BenchmarkIteration;
use crate::benchmark::measurement::{Measurement, Measurements};
use crate::benchmark::quantity::{const_time_from_seconds, Time, TimeQuantity};
use crate::command::Command;
use crate::options::{
CmdFailureAction, CommandOutputPolicy, ExecutorKind, Options, OutputStyleOption,
Expand All @@ -20,6 +18,7 @@ use crate::output::format::{format_duration, format_duration_unit};
use crate::output::progress_bar::get_progress_bar;
use crate::output::warnings::{OutlierWarningOptions, Warnings};
use crate::parameter::ParameterNameAndValue;
use crate::quantity::{self, const_time_from_seconds, Time, TimeQuantity};
use benchmark_result::BenchmarkResult;

use anyhow::{anyhow, Result};
Expand Down
2 changes: 1 addition & 1 deletion src/benchmark/relative_speed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::cmp::Ordering;

use super::benchmark_result::BenchmarkResult;
use crate::{
benchmark::quantity::{self, Ratio, Time, TimeQuantity},
options::SortOrder,
quantity::{self, Ratio, Time, TimeQuantity},
};

#[derive(Debug)]
Expand Down
4 changes: 2 additions & 2 deletions src/export/csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use csv::WriterBuilder;

use super::Exporter;
use crate::benchmark::benchmark_result::BenchmarkResult;
use crate::benchmark::quantity::{second, TimeQuantity};
use crate::options::SortOrder;
use crate::quantity::{second, TimeQuantity};
use crate::util::units::Unit;

use anyhow::Result;
Expand Down Expand Up @@ -65,7 +65,7 @@ impl Exporter for CsvExporter {
fn test_csv() {
use crate::benchmark::benchmark_result::Parameter;
use crate::benchmark::measurement::{Measurement, Measurements};
use crate::benchmark::quantity::{Information, InformationQuantity, Time, TimeQuantity};
use crate::quantity::{Information, InformationQuantity, Time, TimeQuantity};

use std::collections::BTreeMap;
use std::process::ExitStatus;
Expand Down
2 changes: 1 addition & 1 deletion src/export/tests.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use super::Exporter;
use crate::benchmark::benchmark_result::BenchmarkResult;
use crate::benchmark::measurement::{Measurement, Measurements};
use crate::benchmark::quantity::{Information, InformationQuantity, Time, TimeQuantity};
use crate::export::asciidoc::AsciidocExporter;
use crate::export::orgmode::OrgmodeExporter;
use crate::quantity::{Information, InformationQuantity, Time, TimeQuantity};
use crate::util::units::Unit;
use crate::{export::markdown::MarkdownExporter, options::SortOrder};
use std::collections::BTreeMap;
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub mod options;
pub mod outlier_detection;
pub mod output;
pub mod parameter;
pub mod quantity;
pub mod timer;
pub mod util;

Expand Down
2 changes: 1 addition & 1 deletion src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use std::{cmp, env, fmt, io};
use anyhow::ensure;
use clap::ArgMatches;

use crate::benchmark::quantity::{Time, TimeQuantity};
use crate::command::Commands;
use crate::error::OptionsError;
use crate::quantity::{Time, TimeQuantity};
use crate::util::units::Unit;

use anyhow::Result;
Expand Down
2 changes: 1 addition & 1 deletion src/output/format.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
benchmark::quantity::{Time, TimeQuantity},
quantity::{Time, TimeQuantity},
util::units::Unit,
};

Expand Down
2 changes: 1 addition & 1 deletion src/output/warnings.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::fmt;

use crate::benchmark::quantity::{millisecond, Time, TimeQuantity};
use crate::benchmark::MIN_EXECUTION_TIME;
use crate::output::format::format_duration;
use crate::quantity::{millisecond, Time, TimeQuantity};

pub struct OutlierWarningOptions {
pub warmup_in_use: bool,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/timer/unix_timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::process::{Child, ExitStatus};

use anyhow::Result;

use crate::benchmark::quantity::{Information, InformationQuantity, Time, TimeQuantity};
use crate::quantity::{Information, InformationQuantity, Time, TimeQuantity};

#[derive(Debug, Copy, Clone)]
struct ResourceUsage {
Expand Down
2 changes: 1 addition & 1 deletion src/timer/wall_clock_timer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::time::Instant;

use crate::benchmark::quantity::{Time, TimeQuantity};
use crate::quantity::{Time, TimeQuantity};

pub struct WallClockTimer {
start: Instant,
Expand Down
2 changes: 1 addition & 1 deletion src/timer/windows_timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use windows_sys::{
},
};

use crate::benchmark::quantity::{Information, InformationQuantity, Time, TimeQuantity};
use crate::quantity::{Information, InformationQuantity, Time, TimeQuantity};

#[cfg(not(feature = "windows_process_extensions_main_thread_handle"))]
#[allow(non_upper_case_globals)]
Expand Down
2 changes: 1 addition & 1 deletion src/util/units.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! This module contains common units.
use crate::benchmark::quantity::{microsecond, millisecond, second, Time, TimeQuantity};
use crate::quantity::{microsecond, millisecond, second, Time, TimeQuantity};

/// Supported time units
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
Expand Down

0 comments on commit 3cdae0f

Please sign in to comment.