Skip to content
Myr

Export list of runtimes to JSON

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

authored by sharkdp · committed by David Peter · parent 5fb66db · Browse files · 3 files+32 added−2 removed
This commit

State

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

Diff stats

3 files+32 added−2 removed

  • other:+32 added−2 removed

3 files+32 added−2 removed

modified:src/hyperfine/export/csv.rs+26 added-2 removed
1use super::{ExportEntry, Exporter};23use csv::WriterBuilder;3use std::io::{Error, ErrorKind, Result};45use csv::WriterBuilder;67use hyperfine::internal::Second;89/// Set of values that will be exported.10#[derive(Debug, Serialize)]11pub struct CsvEntry {12 command: String,13 mean: Second,14 stddev: Second,15 user: Second,16 system: Second,17 min: Second,18 max: Second,19}202122#[derive(Default)]23pub struct CsvExporter {}2425impl Exporter for CsvExporter {26 fn serialize(&self, results: &Vec<ExportEntry>) -> Result<Vec<u8>> {27 let mut writer = WriterBuilder::new().from_writer(vec![]);28 for res in results {13 writer.serialize(res)?;29 writer.serialize(&CsvEntry {30 command: res.command.clone(),31 mean: res.mean,32 stddev: res.stddev,33 user: res.user,34 system: res.system,35 min: res.min,36 max: res.max,37 })?;38 }3940 writer41 .into_inner()
3 unmodified lines
modified:src/hyperfine/export/mod.rs+5 added
32 unmodified lines
33 min: Second,3435 /// Max time measured36 max: Second,3738 /// All run time measurements39 times: Vec<Second>,40}4142impl ExportEntry {43 /// Create a new entry with the given values.
4 unmodified lines
48 user: Second,49 system: Second,50 min: Second,51 max: Second,52 times: Vec<Second>,53 ) -> Self {54 ExportEntry {55 command,56 mean,
1 unmodified line
58 user,59 system,60 min,61 max,62 times,63 }64 }65}66
65 unmodified lines
modified:src/hyperfine/benchmark.rs+1 added
300 unmodified lines
301 user_mean,302 system_mean,303 t_min,304 t_max,305 times_real,306 ))307}