mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-03 01:21:25 +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,
|
system_mean,
|
||||||
t_min,
|
t_min,
|
||||||
t_max,
|
t_max,
|
||||||
|
times_real,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,24 @@
|
|||||||
use super::{ExportEntry, Exporter};
|
use super::{ExportEntry, Exporter};
|
||||||
|
|
||||||
use csv::WriterBuilder;
|
|
||||||
use std::io::{Error, ErrorKind, Result};
|
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)]
|
#[derive(Default)]
|
||||||
pub struct CsvExporter {}
|
pub struct CsvExporter {}
|
||||||
|
|
||||||
@@ -10,7 +26,15 @@ impl Exporter for CsvExporter {
|
|||||||
fn serialize(&self, results: &Vec<ExportEntry>) -> Result<Vec<u8>> {
|
fn serialize(&self, results: &Vec<ExportEntry>) -> Result<Vec<u8>> {
|
||||||
let mut writer = WriterBuilder::new().from_writer(vec![]);
|
let mut writer = WriterBuilder::new().from_writer(vec![]);
|
||||||
for res in results {
|
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
|
writer
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ pub struct ExportEntry {
|
|||||||
|
|
||||||
/// Max time measured
|
/// Max time measured
|
||||||
max: Second,
|
max: Second,
|
||||||
|
|
||||||
|
/// All run time measurements
|
||||||
|
times: Vec<Second>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExportEntry {
|
impl ExportEntry {
|
||||||
@@ -46,6 +49,7 @@ impl ExportEntry {
|
|||||||
system: Second,
|
system: Second,
|
||||||
min: Second,
|
min: Second,
|
||||||
max: Second,
|
max: Second,
|
||||||
|
times: Vec<Second>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
ExportEntry {
|
ExportEntry {
|
||||||
command,
|
command,
|
||||||
@@ -55,6 +59,7 @@ impl ExportEntry {
|
|||||||
system,
|
system,
|
||||||
min,
|
min,
|
||||||
max,
|
max,
|
||||||
|
times,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user