mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-01 08:50:19 +00:00
Flat directory/module structure
This commit is contained in:
1 parent
d31936ec28
commit
30c381fe2a
27 files changed
+70
-71
No files matched your search
@@ -0,0 +1,27 @@
|
||||
use super::Exporter;
|
||||
use crate::benchmark_result::BenchmarkResult;
|
||||
use crate::units::Unit;
|
||||
|
||||
use std::io::{Error, ErrorKind, Result};
|
||||
|
||||
use serde::*;
|
||||
use serde_json::to_vec_pretty;
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
struct HyperfineSummary<'a> {
|
||||
results: &'a [BenchmarkResult],
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct JsonExporter {}
|
||||
|
||||
impl Exporter for JsonExporter {
|
||||
fn serialize(&self, results: &[BenchmarkResult], _unit: Option<Unit>) -> Result<Vec<u8>> {
|
||||
let mut output = to_vec_pretty(&HyperfineSummary { results });
|
||||
for content in output.iter_mut() {
|
||||
content.push(b'\n');
|
||||
}
|
||||
|
||||
output.map_err(|e| Error::new(ErrorKind::Other, e))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user