Skip to content
Myr

Format CSV measurements through FormatQuantity

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Peter · committed by David Peter · parent 4aa36c8 · Browse files · 1 file+13 added−12 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+13 added−12 removed

  • other:+13 added−12 removed

1 file+13 added−12 removed

modified:src/export/csv.rs+13 added-12 removed
3 unmodified lines
45use super::Exporter;6use crate::benchmark::benchmark_result::BenchmarkResult;7use crate::options::SortOrder;8use crate::quantity::{second, TimeUnit};8use crate::quantity::{FormatQuantity, TimeUnit};910use anyhow::Result;1112#[derive(Default)]
5 unmodified lines
18 results: &[BenchmarkResult],19 _unit: Option<TimeUnit>,20 _sort_order: SortOrder,21 ) -> Result<Vec<u8>> {22 const CSV_UNIT: TimeUnit = TimeUnit::Second;23 const CSV_PRECISION: usize = 6;2425 let mut writer = WriterBuilder::new().from_writer(vec![]);26
15 unmodified lines
4243 for res in results {44 let mut fields = vec![Cow::Borrowed(res.command.as_bytes())];45 for f in &[45 res.mean_wall_clock_time().get::<second>(),46 res.measurements47 .stddev()48 .unwrap_or_default()49 .get::<second>(),50 res.measurements.median().get::<second>(),51 res.measurements.time_user_mean().get::<second>(),52 res.measurements.time_system_mean().get::<second>(),53 res.measurements.min().get::<second>(),54 res.measurements.max().get::<second>(),46 res.mean_wall_clock_time(),47 res.measurements.stddev().unwrap_or_default(),48 res.measurements.median(),49 res.measurements.time_user_mean(),50 res.measurements.time_system_mean(),51 res.measurements.min(),52 res.measurements.max(),53 ] {56 fields.push(Cow::Owned(format!("{f:.CSV_PRECISION$}").into_bytes()))54 fields.push(Cow::Owned(55 f.format_with_precision(CSV_UNIT, CSV_PRECISION)56 .into_bytes(),57 ))58 }59 for v in res.parameters.values() {60 fields.push(Cow::Borrowed(v.value.as_bytes()))61 }
124 unmodified lines