mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-01 08:50:19 +00:00
Move BenchmarkResult to new file
This commit is contained in:
1 parent
cbfd9f5b41
commit
9b328ff354
10 files changed
+86
-84
No files matched your search
@@ -5,6 +5,7 @@ use std::process::{ExitStatus, Stdio};
|
||||
use colored::*;
|
||||
use statistical::{mean, median, standard_deviation};
|
||||
|
||||
use crate::hyperfine::benchmark_result::BenchmarkResult;
|
||||
use crate::hyperfine::command::Command;
|
||||
use crate::hyperfine::format::{format_duration, format_duration_unit};
|
||||
use crate::hyperfine::internal::{get_progress_bar, max, min, MIN_EXECUTION_TIME};
|
||||
@@ -13,7 +14,6 @@ use crate::hyperfine::outlier_detection::{modified_zscores, OUTLIER_THRESHOLD};
|
||||
use crate::hyperfine::shell::execute_and_time;
|
||||
use crate::hyperfine::timer::wallclocktimer::WallClockTimer;
|
||||
use crate::hyperfine::timer::{TimerStart, TimerStop};
|
||||
use crate::hyperfine::types::BenchmarkResult;
|
||||
use crate::hyperfine::units::Second;
|
||||
use crate::hyperfine::warnings::Warnings;
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
use serde::Serialize;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use crate::hyperfine::units::Second;
|
||||
|
||||
/// Set of values that will be exported.
|
||||
// NOTE: `serde` is used for JSON serialization, but not for CSV serialization due to the
|
||||
// `parameters` map. Update `src/hyperfine/export/csv.rs` with new fields, as appropriate.
|
||||
#[derive(Debug, Default, Clone, Serialize, PartialEq)]
|
||||
pub struct BenchmarkResult {
|
||||
/// The command that was run
|
||||
pub command: String,
|
||||
|
||||
/// The mean run time
|
||||
pub mean: Second,
|
||||
|
||||
/// The standard deviation of all run times
|
||||
pub stddev: Second,
|
||||
|
||||
/// The median run time
|
||||
pub median: Second,
|
||||
|
||||
/// Time spend in user space
|
||||
pub user: Second,
|
||||
|
||||
/// Time spent in system space
|
||||
pub system: Second,
|
||||
|
||||
/// Min time measured
|
||||
pub min: Second,
|
||||
|
||||
/// Max time measured
|
||||
pub max: Second,
|
||||
|
||||
/// All run time measurements
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub times: Option<Vec<Second>>,
|
||||
|
||||
/// All run exit codes
|
||||
pub exit_codes: Vec<Option<i32>>,
|
||||
|
||||
/// Any parameter values used
|
||||
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
|
||||
pub parameters: BTreeMap<String, String>,
|
||||
}
|
||||
|
||||
impl BenchmarkResult {
|
||||
/// Create a new entry with the given values.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
command: String,
|
||||
mean: Second,
|
||||
stddev: Second,
|
||||
median: Second,
|
||||
user: Second,
|
||||
system: Second,
|
||||
min: Second,
|
||||
max: Second,
|
||||
times: Vec<Second>,
|
||||
exit_codes: Vec<Option<i32>>,
|
||||
parameters: BTreeMap<String, String>,
|
||||
) -> Self {
|
||||
BenchmarkResult {
|
||||
command,
|
||||
mean,
|
||||
stddev,
|
||||
median,
|
||||
user,
|
||||
system,
|
||||
min,
|
||||
max,
|
||||
times: Some(times),
|
||||
exit_codes,
|
||||
parameters,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::Exporter;
|
||||
|
||||
use crate::hyperfine::benchmark_result::BenchmarkResult;
|
||||
use crate::hyperfine::format::format_duration_value;
|
||||
use crate::hyperfine::types::BenchmarkResult;
|
||||
use crate::hyperfine::units::Unit;
|
||||
|
||||
use std::io::Result;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::Exporter;
|
||||
|
||||
use crate::hyperfine::types::BenchmarkResult;
|
||||
use crate::hyperfine::benchmark_result::BenchmarkResult;
|
||||
use crate::hyperfine::units::Unit;
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::Exporter;
|
||||
use crate::hyperfine::types::BenchmarkResult;
|
||||
use crate::hyperfine::benchmark_result::BenchmarkResult;
|
||||
use crate::hyperfine::units::Unit;
|
||||
|
||||
use std::io::{Error, ErrorKind, Result};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use super::Exporter;
|
||||
|
||||
use crate::hyperfine::benchmark_result::BenchmarkResult;
|
||||
use crate::hyperfine::format::format_duration_value;
|
||||
use crate::hyperfine::internal::{compute_relative_speed, BenchmarkResultWithRelativeSpeed};
|
||||
use crate::hyperfine::types::BenchmarkResult;
|
||||
use crate::hyperfine::units::Unit;
|
||||
|
||||
use std::io::{Error, ErrorKind, Result};
|
||||
|
||||
@@ -11,7 +11,7 @@ use self::markdown::MarkdownExporter;
|
||||
use std::fs::{File, OpenOptions};
|
||||
use std::io::{Result, Write};
|
||||
|
||||
use crate::hyperfine::types::BenchmarkResult;
|
||||
use crate::hyperfine::benchmark_result::BenchmarkResult;
|
||||
use crate::hyperfine::units::Unit;
|
||||
|
||||
/// The desired form of exporter to use for a given file.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use colored::*;
|
||||
use indicatif::{ProgressBar, ProgressStyle};
|
||||
|
||||
use crate::hyperfine::benchmark_result::BenchmarkResult;
|
||||
use crate::hyperfine::options::OutputStyleOption;
|
||||
use crate::hyperfine::types::BenchmarkResult;
|
||||
use crate::hyperfine::units::{Scalar, Second};
|
||||
|
||||
use std::cmp::Ordering;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
pub mod app;
|
||||
pub mod benchmark;
|
||||
pub mod benchmark_result;
|
||||
pub mod command;
|
||||
pub mod error;
|
||||
pub mod export;
|
||||
|
||||
+1
-77
@@ -1,13 +1,10 @@
|
||||
use serde::*;
|
||||
use std::collections::BTreeMap;
|
||||
use serde::Serialize;
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt;
|
||||
|
||||
use rust_decimal::prelude::ToPrimitive;
|
||||
use rust_decimal::Decimal;
|
||||
|
||||
use crate::hyperfine::units::Second;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Copy, PartialEq, Eq)]
|
||||
#[serde(untagged)]
|
||||
pub enum NumericType {
|
||||
@@ -64,76 +61,3 @@ impl<'a> ToString for ParameterValue {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Set of values that will be exported.
|
||||
// NOTE: `serde` is used for JSON serialization, but not for CSV serialization due to the
|
||||
// `parameters` map. Update `src/hyperfine/export/csv.rs` with new fields, as appropriate.
|
||||
#[derive(Debug, Default, Clone, Serialize, PartialEq)]
|
||||
pub struct BenchmarkResult {
|
||||
/// The command that was run
|
||||
pub command: String,
|
||||
|
||||
/// The mean run time
|
||||
pub mean: Second,
|
||||
|
||||
/// The standard deviation of all run times
|
||||
pub stddev: Second,
|
||||
|
||||
/// The median run time
|
||||
pub median: Second,
|
||||
|
||||
/// Time spend in user space
|
||||
pub user: Second,
|
||||
|
||||
/// Time spent in system space
|
||||
pub system: Second,
|
||||
|
||||
/// Min time measured
|
||||
pub min: Second,
|
||||
|
||||
/// Max time measured
|
||||
pub max: Second,
|
||||
|
||||
/// All run time measurements
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub times: Option<Vec<Second>>,
|
||||
|
||||
/// All run exit codes
|
||||
pub exit_codes: Vec<Option<i32>>,
|
||||
|
||||
/// Any parameter values used
|
||||
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
|
||||
pub parameters: BTreeMap<String, String>,
|
||||
}
|
||||
|
||||
impl BenchmarkResult {
|
||||
/// Create a new entry with the given values.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
command: String,
|
||||
mean: Second,
|
||||
stddev: Second,
|
||||
median: Second,
|
||||
user: Second,
|
||||
system: Second,
|
||||
min: Second,
|
||||
max: Second,
|
||||
times: Vec<Second>,
|
||||
exit_codes: Vec<Option<i32>>,
|
||||
parameters: BTreeMap<String, String>,
|
||||
) -> Self {
|
||||
BenchmarkResult {
|
||||
command,
|
||||
mean,
|
||||
stddev,
|
||||
median,
|
||||
user,
|
||||
system,
|
||||
min,
|
||||
max,
|
||||
times: Some(times),
|
||||
exit_codes,
|
||||
parameters,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user