Quantity API cleanup

This commit is contained in:
David Peter authored and David Peter committed 2026-10-05 15:59:56 +02:00
1 parent 0257df96bd
commit 4badeb6312
10 files changed
+265 -170

No files matched your search

+1 -2
View File
@@ -5,8 +5,7 @@ use csv::WriterBuilder;
use super::Exporter;
use crate::benchmark::benchmark_result::BenchmarkResult;
use crate::options::SortOrder;
use crate::quantity::{second, TimeQuantity};
use crate::util::units::TimeUnit;
use crate::quantity::{second, TimeQuantity, TimeUnit};
use anyhow::Result;
+1 -1
View File
@@ -4,7 +4,7 @@ use serde_json::to_vec_pretty;
use super::Exporter;
use crate::benchmark::benchmark_result::BenchmarkResult;
use crate::options::SortOrder;
use crate::util::units::TimeUnit;
use crate::quantity::TimeUnit;
use anyhow::Result;
+9 -3
View File
@@ -51,9 +51,12 @@ pub trait MarkupExporter {
let result = &entry.result;
// prepare data row strings
let cmd_str = result.command_with_unused_parameters().replace('|', "\\|");
let mean_str = format_duration_value(result.mean_wall_clock_time(), Some(time_unit)).0;
let mean_str = result
.mean_wall_clock_time()
.format_value_auto(Some(time_unit))
.0;
let stddev_str = if let Some(stddev) = result.measurements.stddev() {
format!(" ± {}", format_duration_value(stddev, Some(time_unit)).0)
format!(" ± {}", stddev.format_value_auto(Some(time_unit)).0)
} else {
"".into()
};
@@ -114,7 +117,10 @@ pub trait MarkupExporter {
fn determine_unit_from_results(results: &[BenchmarkResult]) -> TimeUnit {
if let Some(first_result) = results.first() {
// Use the first BenchmarkResult entry to determine the unit for all entries.
format_duration_value(first_result.mean_wall_clock_time(), None).1
first_result
.mean_wall_clock_time()
.format_auto_with_unit(None)
.1
} else {
// Default to `Second`.
TimeUnit::Second
+1 -1
View File
@@ -18,7 +18,7 @@ use self::orgmode::OrgmodeExporter;
use crate::benchmark::benchmark_result::BenchmarkResult;
use crate::options::SortOrder;
use crate::util::units::TimeUnit;
use crate::quantity::TimeUnit;
use anyhow::{Context, Result};
use clap::ArgMatches;
+1 -2
View File
@@ -3,8 +3,7 @@ use crate::benchmark::benchmark_result::BenchmarkResult;
use crate::benchmark::measurement::{Measurement, Measurements};
use crate::export::asciidoc::AsciidocExporter;
use crate::export::orgmode::OrgmodeExporter;
use crate::quantity::{byte, second, Information, Time, TimeQuantity};
use crate::util::units::TimeUnit;
use crate::quantity::{byte, second, Information, Time, TimeQuantity, TimeUnit};
use crate::{export::markdown::MarkdownExporter, options::SortOrder};
use std::collections::BTreeMap;
use std::process::ExitStatus;