mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-10-31 08:40:18 +00:00
Export list of runtimes to JSON
This commit is contained in:
1 parent
5fb66db100
commit
8a25885714
3 files changed
+32
-2
No files matched your search
@@ -302,5 +302,6 @@ pub fn run_benchmark(
|
||||
system_mean,
|
||||
t_min,
|
||||
t_max,
|
||||
times_real,
|
||||
))
|
||||
}
|
||||
@@ -1,8 +1,24 @@
|
||||
use super::{ExportEntry, Exporter};
|
||||
|
||||
use csv::WriterBuilder;
|
||||
use std::io::{Error, ErrorKind, Result};
|
||||
|
||||
use csv::WriterBuilder;
|
||||
|
||||
use hyperfine::internal::Second;
|
||||
|
||||
/// Set of values that will be exported.
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct CsvEntry {
|
||||
command: String,
|
||||
mean: Second,
|
||||
stddev: Second,
|
||||
user: Second,
|
||||
system: Second,
|
||||
min: Second,
|
||||
max: Second,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct CsvExporter {}
|
||||
|
||||
@@ -10,7 +26,15 @@ impl Exporter for CsvExporter {
|
||||
fn serialize(&self, results: &Vec<ExportEntry>) -> Result<Vec<u8>> {
|
||||
let mut writer = WriterBuilder::new().from_writer(vec![]);
|
||||
for res in results {
|
||||
writer.serialize(res)?;
|
||||
writer.serialize(&CsvEntry {
|
||||
command: res.command.clone(),
|
||||
mean: res.mean,
|
||||
stddev: res.stddev,
|
||||
user: res.user,
|
||||
system: res.system,
|
||||
min: res.min,
|
||||
max: res.max,
|
||||
})?;
|
||||
}
|
||||
|
||||
writer
|
||||
|
||||
@@ -34,6 +34,9 @@ pub struct ExportEntry {
|
||||
|
||||
/// Max time measured
|
||||
max: Second,
|
||||
|
||||
/// All run time measurements
|
||||
times: Vec<Second>,
|
||||
}
|
||||
|
||||
impl ExportEntry {
|
||||
@@ -46,6 +49,7 @@ impl ExportEntry {
|
||||
system: Second,
|
||||
min: Second,
|
||||
max: Second,
|
||||
times: Vec<Second>,
|
||||
) -> Self {
|
||||
ExportEntry {
|
||||
command,
|
||||
@@ -55,6 +59,7 @@ impl ExportEntry {
|
||||
system,
|
||||
min,
|
||||
max,
|
||||
times,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user