json.rs
This file
Path
src/export/json.rs
33 lines · 736 bytes · Rust
Last changed by
Merge pull request #962 from sharkdp/codex/quantity-module-layoutDavid Peterbefore adoptionecf8a24
History of this fileTake it
The walk stopped after 200 commits: lines older than ca9e29a point at it.
Fix pipeline!David Peterbefore adoptionca9e29a
lines 1–5why, one step back1use serde::*;2use serde_json::to_vec_pretty;34use super::Exporter;5use crate::benchmark::benchmark_result::BenchmarkResult;Add new --sort optionDavid Peterbefore adoptionac617c8
line 6why, one step back6use crate::options::SortOrder;Merge pull request #962 from sharkdp/codex/quantity-module-layoutDavid Peterbefore adoptionecf8a24
line 7why, one step back7use crate::quantity::TimeUnit;Fix pipeline!David Peterbefore adoptionca9e29a
lines 8–19why, one step back89use anyhow::Result;1011#[derive(Serialize, Debug)]12struct HyperfineSummary<'a> {13 results: &'a [BenchmarkResult],14}1516#[derive(Default)]17pub struct JsonExporter {}1819impl Exporter for JsonExporter {Add new --sort optionDavid Peterbefore adoptionac617c8
lines 20–22why, one step back20 fn serialize(21 &self,22 results: &[BenchmarkResult],Merge pull request #962 from sharkdp/codex/quantity-module-layoutDavid Peterbefore adoptionecf8a24
line 23why, one step back23 _unit: Option<TimeUnit>,Add new --sort optionDavid Peterbefore adoptionac617c8
lines 24–25why, one step back24 _sort_order: SortOrder,25 ) -> Result<Vec<u8>> {Fix pipeline!David Peterbefore adoptionca9e29a
lines 26–33why, one step back26 let mut output = to_vec_pretty(&HyperfineSummary { results });27 if let Ok(ref mut content) = output {28 content.push(b'\n');29 }3031 Ok(output?)32 }33}