From 3cdae0fe9c83eddf9725398ef6b5b9a3fd831b1f Mon Sep 17 00:00:00 2001 From: David Peter Date: Sat, 4 Jan 2025 22:26:01 +0100 Subject: [PATCH] Move quantity module --- src/benchmark/benchmark_result.rs | 3 ++- src/benchmark/executor.rs | 6 +++--- src/benchmark/measurement.rs | 4 ++-- src/benchmark/mod.rs | 3 +-- src/benchmark/relative_speed.rs | 2 +- src/export/csv.rs | 4 ++-- src/export/tests.rs | 2 +- src/main.rs | 1 + src/options.rs | 2 +- src/output/format.rs | 2 +- src/output/warnings.rs | 2 +- src/{benchmark => }/quantity.rs | 0 src/timer/unix_timer.rs | 2 +- src/timer/wall_clock_timer.rs | 2 +- src/timer/windows_timer.rs | 2 +- src/util/units.rs | 2 +- 16 files changed, 20 insertions(+), 19 deletions(-) rename src/{benchmark => }/quantity.rs (100%) diff --git a/src/benchmark/benchmark_result.rs b/src/benchmark/benchmark_result.rs index 2bae235ac..1012d31e1 100644 --- a/src/benchmark/benchmark_result.rs +++ b/src/benchmark/benchmark_result.rs @@ -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)] diff --git a/src/benchmark/executor.rs b/src/benchmark/executor.rs index fbef8e052..82298ad30 100644 --- a/src/benchmark/executor.rs +++ b/src/benchmark/executor.rs @@ -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; diff --git a/src/benchmark/measurement.rs b/src/benchmark/measurement.rs index 28a2735f2..0bd07cef2 100644 --- a/src/benchmark/measurement.rs +++ b/src/benchmark/measurement.rs @@ -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(exit_status: &ExitStatus, serializer: S) -> Result diff --git a/src/benchmark/mod.rs b/src/benchmark/mod.rs index 5b47d03a1..ed78ec52c 100644 --- a/src/benchmark/mod.rs +++ b/src/benchmark/mod.rs @@ -1,7 +1,6 @@ pub mod benchmark_result; pub mod executor; pub mod measurement; -pub mod quantity; pub mod relative_speed; pub mod scheduler; @@ -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, @@ -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}; diff --git a/src/benchmark/relative_speed.rs b/src/benchmark/relative_speed.rs index 68570dd7b..6f9cf8f96 100644 --- a/src/benchmark/relative_speed.rs +++ b/src/benchmark/relative_speed.rs @@ -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)] diff --git a/src/export/csv.rs b/src/export/csv.rs index ca8a14b14..0c15f89cd 100644 --- a/src/export/csv.rs +++ b/src/export/csv.rs @@ -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; @@ -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; diff --git a/src/export/tests.rs b/src/export/tests.rs index 3e67b11ee..67fdd7aff 100644 --- a/src/export/tests.rs +++ b/src/export/tests.rs @@ -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; diff --git a/src/main.rs b/src/main.rs index 2a9750503..fc8b5580a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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; diff --git a/src/options.rs b/src/options.rs index 01e54239a..3ec4fe828 100644 --- a/src/options.rs +++ b/src/options.rs @@ -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; diff --git a/src/output/format.rs b/src/output/format.rs index 8a5f5d1ea..e3fbb841c 100644 --- a/src/output/format.rs +++ b/src/output/format.rs @@ -1,5 +1,5 @@ use crate::{ - benchmark::quantity::{Time, TimeQuantity}, + quantity::{Time, TimeQuantity}, util::units::Unit, }; diff --git a/src/output/warnings.rs b/src/output/warnings.rs index 6802006d4..893cb2d34 100644 --- a/src/output/warnings.rs +++ b/src/output/warnings.rs @@ -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, diff --git a/src/benchmark/quantity.rs b/src/quantity.rs similarity index 100% rename from src/benchmark/quantity.rs rename to src/quantity.rs diff --git a/src/timer/unix_timer.rs b/src/timer/unix_timer.rs index 524a97544..29782484f 100644 --- a/src/timer/unix_timer.rs +++ b/src/timer/unix_timer.rs @@ -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 { diff --git a/src/timer/wall_clock_timer.rs b/src/timer/wall_clock_timer.rs index 2a2c4609c..68a543a90 100644 --- a/src/timer/wall_clock_timer.rs +++ b/src/timer/wall_clock_timer.rs @@ -1,6 +1,6 @@ use std::time::Instant; -use crate::benchmark::quantity::{Time, TimeQuantity}; +use crate::quantity::{Time, TimeQuantity}; pub struct WallClockTimer { start: Instant, diff --git a/src/timer/windows_timer.rs b/src/timer/windows_timer.rs index 3ee6bfaa0..e4fb5699c 100644 --- a/src/timer/windows_timer.rs +++ b/src/timer/windows_timer.rs @@ -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)] diff --git a/src/util/units.rs b/src/util/units.rs index 15ca1b225..614477a0b 100644 --- a/src/util/units.rs +++ b/src/util/units.rs @@ -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)]