Flat directory/module structure

This commit is contained in:
David Peter authored and David Peter committed 2021-08-24 22:44:08 +02:00
1 parent d31936ec28
commit 30c381fe2a
27 files changed
+70 -71

No files matched your search

+27
View File
@@ -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))
}
}