Skip to content
Myr

json.rs

This file

Path

src/export/json.rs

27 lines · 634 bytes · Rust

Last changed by

Move functionality to schedulerDavid Peterbefore adoptiondcfeede

History of this file

Take it

Flat directory/module structureDavid Peterbefore adoption30c381f

lines 1–2why, one step back
1use serde::*;
2use serde_json::to_vec_pretty;

Re-order importsDavid Peterbefore adoption9df6174

lines 3–4why, one step back
3
4use super::Exporter;

Move functionality to schedulerDavid Peterbefore adoptiondcfeede

line 5why, one step back
5use crate::benchmark::benchmark_result::BenchmarkResult;

Move a few modules to utilDavid Peterbefore adoption5c634c9

line 6why, one step back
6use crate::util::units::Unit;

Flat directory/module structureDavid Peterbefore adoption30c381f

line 7why, one step back
7

Unified error handlingDavid Peterbefore adoption2040810

lines 8–9why, one step back
8use anyhow::Result;
9

Flat directory/module structureDavid Peterbefore adoption30c381f

lines 10–24why, one step back
10#[derive(Serialize, Debug)]
11struct HyperfineSummary<'a> {12 results: &'a [BenchmarkResult],13}1415#[derive(Default)]16pub struct JsonExporter {}1718impl Exporter for JsonExporter {19 fn serialize(&self, results: &[BenchmarkResult], _unit: Option<Unit>) -> Result<Vec<u8>> {20 let mut output = to_vec_pretty(&HyperfineSummary { results });21 for content in output.iter_mut() {22 content.push(b'\n');23 }24

Unified error handlingDavid Peterbefore adoption2040810

line 25why, one step back
25 Ok(output?)

Flat directory/module structureDavid Peterbefore adoption30c381f

lines 26–27why, one step back
26 }
27}