mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-02 17:11:28 +00:00
Mark reference commands in JSON exports
This commit is contained in:
1 parent
95118147af
commit
cb021e64b9
1 file changed
+6
-2
+6
-2
@@ -28,6 +28,8 @@ struct HyperfineSummary<'a> {
|
|||||||
struct JsonBenchmarkResult<'a> {
|
struct JsonBenchmarkResult<'a> {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
result: &'a BenchmarkResult,
|
result: &'a BenchmarkResult,
|
||||||
|
#[serde(skip_serializing_if = "std::ops::Not::not")]
|
||||||
|
is_reference: bool,
|
||||||
summary: BenchmarkSummary,
|
summary: BenchmarkSummary,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,15 +121,17 @@ impl Exporter for JsonExporter {
|
|||||||
results: &[BenchmarkResult],
|
results: &[BenchmarkResult],
|
||||||
_time_unit: Option<TimeUnit>,
|
_time_unit: Option<TimeUnit>,
|
||||||
_sort_order: SortOrder,
|
_sort_order: SortOrder,
|
||||||
_reference_index: Option<usize>,
|
reference_index: Option<usize>,
|
||||||
) -> Result<Vec<u8>> {
|
) -> Result<Vec<u8>> {
|
||||||
let mut output = to_vec_pretty(&HyperfineSummary {
|
let mut output = to_vec_pretty(&HyperfineSummary {
|
||||||
schema_version: JSON_SCHEMA_VERSION,
|
schema_version: JSON_SCHEMA_VERSION,
|
||||||
metadata: &self.metadata,
|
metadata: &self.metadata,
|
||||||
results: results
|
results: results
|
||||||
.iter()
|
.iter()
|
||||||
.map(|result| JsonBenchmarkResult {
|
.enumerate()
|
||||||
|
.map(|(index, result)| JsonBenchmarkResult {
|
||||||
result,
|
result,
|
||||||
|
is_reference: reference_index == Some(index),
|
||||||
summary: BenchmarkSummary::from_measurements(&result.measurements),
|
summary: BenchmarkSummary::from_measurements(&result.measurements),
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
|
|||||||
Reference in new issue
Block a user