Files
hyperfine/src/export/tests.rs
T

482 lines
19 KiB
Rust
Raw Normal View History

2024-12-29 12:46:37 +01:00
use super::Exporter;
2026-10-05 14:15:34 +02:00
use crate::benchmark::benchmark_result::BenchmarkResult;
use crate::benchmark::measurement::{Measurement, Measurements};
2024-12-29 13:10:50 +01:00
use crate::export::asciidoc::AsciidocExporter;
use crate::export::markdown::MarkdownExporter;
2024-12-29 13:10:50 +01:00
use crate::export::orgmode::OrgmodeExporter;
use crate::metric::{MetricSelection, Unit};
use crate::quantity::{byte, second, Information, Time, Zero};
2024-12-29 12:46:37 +01:00
use std::collections::BTreeMap;
2026-10-05 12:46:10 +02:00
use std::process::ExitStatus;
2024-12-29 12:46:37 +01:00
fn get_output<E: Exporter + Default>(results: &[BenchmarkResult], unit: Option<Unit>) -> String {
2024-12-29 13:10:50 +01:00
let exporter = E::default();
String::from_utf8(
exporter
.serialize(
results,
MetricSelection {
unit,
..MetricSelection::default()
},
)
.unwrap(),
)
.unwrap()
2024-12-29 12:46:37 +01:00
}
2024-12-29 13:10:50 +01:00
/// Ensure the makrup output includes the table header and the multiple
2024-12-29 12:46:37 +01:00
/// benchmark results as a table. The list of actual times is not included
/// in the output.
///
/// This also demonstrates that the first entry's units (ms) are used to set
2024-12-29 13:10:50 +01:00
/// the units for all entries when the time unit is not specified.
2024-12-29 12:46:37 +01:00
#[test]
2024-12-29 13:10:50 +01:00
fn test_markup_export_auto_ms() {
2024-12-29 12:46:37 +01:00
let results = [
BenchmarkResult {
command: String::from("sleep 0.1"),
2026-10-05 18:11:10 +02:00
name: None,
2026-10-05 21:02:52 +02:00
display_name: String::from("sleep 0.1"),
2026-10-05 14:15:34 +02:00
measurements: Measurements::new(vec![
Measurement {
2026-10-05 14:18:58 +02:00
time_wall_clock: Time::new::<second>(0.09),
2026-10-06 13:34:03 +02:00
time_cpu: Time::new::<second>(0.09),
2026-10-05 14:18:58 +02:00
time_user: Time::new::<second>(0.09),
2026-10-05 14:17:14 +02:00
time_system: Time::zero(),
memory_peak_resident: Some(Information::new::<byte>(1024.)),
hardware_counters: Default::default(),
2026-10-05 14:16:20 +02:00
exit_status: ExitStatus::default(),
2026-10-05 12:46:10 +02:00
},
2026-10-05 14:15:34 +02:00
Measurement {
2026-10-05 14:18:58 +02:00
time_wall_clock: Time::new::<second>(0.10),
2026-10-06 13:34:03 +02:00
time_cpu: Time::new::<second>(0.10),
2026-10-05 14:18:58 +02:00
time_user: Time::new::<second>(0.10),
2026-10-05 14:17:14 +02:00
time_system: Time::zero(),
memory_peak_resident: Some(Information::new::<byte>(1024.)),
hardware_counters: Default::default(),
2026-10-05 14:16:20 +02:00
exit_status: ExitStatus::default(),
2026-10-05 12:46:10 +02:00
},
2026-10-05 14:15:34 +02:00
Measurement {
2026-10-05 14:18:58 +02:00
time_wall_clock: Time::new::<second>(0.14),
2026-10-06 13:34:03 +02:00
time_cpu: Time::new::<second>(0.14),
2026-10-05 14:18:58 +02:00
time_user: Time::new::<second>(0.14),
2026-10-05 14:17:14 +02:00
time_system: Time::zero(),
memory_peak_resident: Some(Information::new::<byte>(1024.)),
hardware_counters: Default::default(),
2026-10-05 14:16:20 +02:00
exit_status: ExitStatus::default(),
2026-10-05 12:46:10 +02:00
},
2026-10-05 14:15:02 +02:00
]),
2024-12-29 12:46:37 +01:00
parameters: BTreeMap::new(),
},
BenchmarkResult {
command: String::from("sleep 2"),
2026-10-05 18:11:10 +02:00
name: None,
2026-10-05 21:02:52 +02:00
display_name: String::from("sleep 2"),
2026-10-05 14:15:34 +02:00
measurements: Measurements::new(vec![
Measurement {
2026-10-05 14:18:58 +02:00
time_wall_clock: Time::new::<second>(2.0),
2026-10-06 13:34:03 +02:00
time_cpu: Time::new::<second>(2.0),
2026-10-05 14:18:58 +02:00
time_user: Time::new::<second>(2.0),
2026-10-05 14:17:14 +02:00
time_system: Time::zero(),
memory_peak_resident: Some(Information::new::<byte>(1024.)),
hardware_counters: Default::default(),
2026-10-05 14:16:20 +02:00
exit_status: ExitStatus::default(),
2026-10-05 12:46:10 +02:00
},
2026-10-05 14:15:34 +02:00
Measurement {
2026-10-05 14:18:58 +02:00
time_wall_clock: Time::new::<second>(3.0),
2026-10-06 13:34:03 +02:00
time_cpu: Time::new::<second>(3.0),
2026-10-05 14:18:58 +02:00
time_user: Time::new::<second>(3.0),
2026-10-05 14:17:14 +02:00
time_system: Time::zero(),
memory_peak_resident: Some(Information::new::<byte>(1024.)),
hardware_counters: Default::default(),
2026-10-05 14:16:20 +02:00
exit_status: ExitStatus::default(),
2026-10-05 12:46:10 +02:00
},
2026-10-05 14:15:34 +02:00
Measurement {
2026-10-05 14:18:58 +02:00
time_wall_clock: Time::new::<second>(4.0),
2026-10-06 13:34:03 +02:00
time_cpu: Time::new::<second>(4.0),
2026-10-05 14:18:58 +02:00
time_user: Time::new::<second>(4.0),
2026-10-05 14:17:14 +02:00
time_system: Time::zero(),
memory_peak_resident: Some(Information::new::<byte>(1024.)),
hardware_counters: Default::default(),
2026-10-05 14:16:20 +02:00
exit_status: ExitStatus::default(),
2026-10-05 12:46:10 +02:00
},
2026-10-05 14:15:02 +02:00
]),
2024-12-29 12:46:37 +01:00
parameters: BTreeMap::new(),
},
];
2026-10-06 10:52:49 +02:00
insta::assert_snapshot!(get_output::<MarkdownExporter>(&results, None), @"
| Command | Mean Wall Time [ms] | Min [ms] | Max [ms] | Change |
2024-12-29 12:46:37 +01:00
|:---|---:|---:|---:|---:|
| `sleep 0.1` | 110.0 ± 26.5 | 90.0 | 140.0 | reference |
| `sleep 2` | 3000.0 ± 1000.0 | 2000.0 | 4000.0 | +2627.3% |
2026-10-06 10:52:49 +02:00
");
2024-12-29 13:10:50 +01:00
insta::assert_snapshot!(get_output::<AsciidocExporter>(&results, None), @r#"
2024-12-29 13:10:50 +01:00
[cols="<,>,>,>,>"]
|===
| Command
2026-10-06 10:52:49 +02:00
| Mean Wall Time [ms]
| Min [ms]
| Max [ms]
| Change
2024-12-29 13:10:50 +01:00
| `sleep 0.1`
| 110.0 ± 26.5
| 90.0
| 140.0
| reference
2024-12-29 13:10:50 +01:00
| `sleep 2`
| 3000.0 ± 1000.0
| 2000.0
| 4000.0
| +2627.3%
2024-12-29 13:10:50 +01:00
|===
"#);
2026-10-06 10:52:49 +02:00
insta::assert_snapshot!(get_output::<OrgmodeExporter>(&results, None), @"
| Command | Mean Wall Time [ms] | Min [ms] | Max [ms] | Change |
2024-12-29 13:10:50 +01:00
|--+--+--+--+--|
| =sleep 0.1= | 110.0 ± 26.5 | 90.0 | 140.0 | reference |
| =sleep 2= | 3000.0 ± 1000.0 | 2000.0 | 4000.0 | +2627.3% |
2026-10-06 10:52:49 +02:00
");
2024-12-29 12:46:37 +01:00
}
/// This (again) demonstrates that the first entry's units (s) are used to set
/// the units for all entries when the time unit is not given.
#[test]
2024-12-29 13:10:50 +01:00
fn test_markup_export_auto_s() {
2024-12-29 12:46:37 +01:00
let results = [
BenchmarkResult {
command: String::from("sleep 2"),
2026-10-05 18:11:10 +02:00
name: None,
2026-10-05 21:02:52 +02:00
display_name: String::from("sleep 2"),
2026-10-05 14:15:34 +02:00
measurements: Measurements::new(vec![
Measurement {
2026-10-05 14:18:58 +02:00
time_wall_clock: Time::new::<second>(2.1),
2026-10-06 13:34:03 +02:00
time_cpu: Time::new::<second>(2.1),
2026-10-05 14:18:58 +02:00
time_user: Time::new::<second>(2.1),
2026-10-05 14:17:14 +02:00
time_system: Time::zero(),
memory_peak_resident: Some(Information::new::<byte>(1024.)),
hardware_counters: Default::default(),
2026-10-05 14:16:20 +02:00
exit_status: ExitStatus::default(),
2026-10-05 12:46:10 +02:00
},
2026-10-05 14:15:34 +02:00
Measurement {
2026-10-05 14:18:58 +02:00
time_wall_clock: Time::new::<second>(2.2),
2026-10-06 13:34:03 +02:00
time_cpu: Time::new::<second>(2.2),
2026-10-05 14:18:58 +02:00
time_user: Time::new::<second>(2.2),
2026-10-05 14:17:14 +02:00
time_system: Time::zero(),
memory_peak_resident: Some(Information::new::<byte>(1024.)),
hardware_counters: Default::default(),
2026-10-05 14:16:20 +02:00
exit_status: ExitStatus::default(),
2026-10-05 12:46:10 +02:00
},
2026-10-05 14:15:34 +02:00
Measurement {
2026-10-05 14:18:58 +02:00
time_wall_clock: Time::new::<second>(2.3),
2026-10-06 13:34:03 +02:00
time_cpu: Time::new::<second>(2.3),
2026-10-05 14:18:58 +02:00
time_user: Time::new::<second>(2.3),
2026-10-05 14:17:14 +02:00
time_system: Time::zero(),
memory_peak_resident: Some(Information::new::<byte>(1024.)),
hardware_counters: Default::default(),
2026-10-05 14:16:20 +02:00
exit_status: ExitStatus::default(),
2026-10-05 12:46:10 +02:00
},
2026-10-05 14:15:02 +02:00
]),
2024-12-29 12:46:37 +01:00
parameters: BTreeMap::new(),
},
BenchmarkResult {
command: String::from("sleep 0.1"),
2026-10-05 18:11:10 +02:00
name: None,
2026-10-05 21:02:52 +02:00
display_name: String::from("sleep 0.1"),
2026-10-05 14:15:34 +02:00
measurements: Measurements::new(vec![
Measurement {
2026-10-05 14:18:58 +02:00
time_wall_clock: Time::new::<second>(0.1),
2026-10-06 13:34:03 +02:00
time_cpu: Time::new::<second>(0.1),
2026-10-05 14:18:58 +02:00
time_user: Time::new::<second>(0.1),
2026-10-05 14:17:14 +02:00
time_system: Time::zero(),
memory_peak_resident: Some(Information::new::<byte>(1024.)),
hardware_counters: Default::default(),
2026-10-05 14:16:20 +02:00
exit_status: ExitStatus::default(),
2026-10-05 12:46:10 +02:00
},
2026-10-05 14:15:34 +02:00
Measurement {
2026-10-05 14:18:58 +02:00
time_wall_clock: Time::new::<second>(0.2),
2026-10-06 13:34:03 +02:00
time_cpu: Time::new::<second>(0.2),
2026-10-05 14:18:58 +02:00
time_user: Time::new::<second>(0.2),
2026-10-05 14:17:14 +02:00
time_system: Time::zero(),
memory_peak_resident: Some(Information::new::<byte>(1024.)),
hardware_counters: Default::default(),
2026-10-05 14:16:20 +02:00
exit_status: ExitStatus::default(),
2026-10-05 12:46:10 +02:00
},
2026-10-05 14:15:34 +02:00
Measurement {
2026-10-05 14:18:58 +02:00
time_wall_clock: Time::new::<second>(0.3),
2026-10-06 13:34:03 +02:00
time_cpu: Time::new::<second>(0.3),
2026-10-05 14:18:58 +02:00
time_user: Time::new::<second>(0.3),
2026-10-05 14:17:14 +02:00
time_system: Time::zero(),
memory_peak_resident: Some(Information::new::<byte>(1024.)),
hardware_counters: Default::default(),
2026-10-05 14:16:20 +02:00
exit_status: ExitStatus::default(),
2026-10-05 12:46:10 +02:00
},
2026-10-05 14:15:02 +02:00
]),
2024-12-29 12:46:37 +01:00
parameters: BTreeMap::new(),
},
];
2026-10-06 10:52:49 +02:00
insta::assert_snapshot!(get_output::<MarkdownExporter>(&results, None), @"
| Command | Mean Wall Time [s] | Min [s] | Max [s] | Change |
2024-12-29 12:46:37 +01:00
|:---|---:|---:|---:|---:|
| `sleep 2` | 2.200 ± 0.100 | 2.100 | 2.300 | reference |
| `sleep 0.1` | 0.200 ± 0.100 | 0.100 | 0.300 | -90.9% |
2026-10-06 10:52:49 +02:00
");
2024-12-29 12:46:37 +01:00
insta::assert_snapshot!(get_output::<AsciidocExporter>(&results, None), @r#"
2024-12-29 13:10:50 +01:00
[cols="<,>,>,>,>"]
|===
| Command
2026-10-06 10:52:49 +02:00
| Mean Wall Time [s]
| Min [s]
| Max [s]
| Change
2024-12-29 12:46:37 +01:00
| `sleep 2`
| 2.200 ± 0.100
| 2.100
| 2.300
| reference
2024-12-29 12:46:37 +01:00
| `sleep 0.1`
| 0.200 ± 0.100
| 0.100
| 0.300
| -90.9%
2024-12-29 13:10:50 +01:00
|===
"#);
2026-10-06 10:52:49 +02:00
insta::assert_snapshot!(get_output::<OrgmodeExporter>(&results, None), @"
| Command | Mean Wall Time [s] | Min [s] | Max [s] | Change |
2024-12-29 13:10:50 +01:00
|--+--+--+--+--|
| =sleep 2= | 2.200 ± 0.100 | 2.100 | 2.300 | reference |
| =sleep 0.1= | 0.200 ± 0.100 | 0.100 | 0.300 | -90.9% |
2026-10-06 10:52:49 +02:00
");
2024-12-29 12:46:37 +01:00
}
/// This (again) demonstrates that the given time unit (ms) is used to set
/// the units for all entries.
#[test]
2024-12-29 13:10:50 +01:00
fn test_markup_export_manual_ms() {
2024-12-29 12:46:37 +01:00
let timing_results = [
BenchmarkResult {
command: String::from("sleep 2"),
2026-10-05 18:11:10 +02:00
name: None,
2026-10-05 21:02:52 +02:00
display_name: String::from("sleep 2"),
2026-10-05 14:15:34 +02:00
measurements: Measurements::new(vec![
Measurement {
2026-10-05 14:18:58 +02:00
time_wall_clock: Time::new::<second>(2.1),
2026-10-06 13:34:03 +02:00
time_cpu: Time::new::<second>(2.1),
2026-10-05 14:18:58 +02:00
time_user: Time::new::<second>(2.1),
2026-10-05 14:17:14 +02:00
time_system: Time::zero(),
memory_peak_resident: Some(Information::new::<byte>(1024.)),
hardware_counters: Default::default(),
2026-10-05 14:16:20 +02:00
exit_status: ExitStatus::default(),
2026-10-05 12:46:10 +02:00
},
2026-10-05 14:15:34 +02:00
Measurement {
2026-10-05 14:18:58 +02:00
time_wall_clock: Time::new::<second>(2.2),
2026-10-06 13:34:03 +02:00
time_cpu: Time::new::<second>(2.2),
2026-10-05 14:18:58 +02:00
time_user: Time::new::<second>(2.2),
2026-10-05 14:17:14 +02:00
time_system: Time::zero(),
memory_peak_resident: Some(Information::new::<byte>(1024.)),
hardware_counters: Default::default(),
2026-10-05 14:16:20 +02:00
exit_status: ExitStatus::default(),
2026-10-05 12:46:10 +02:00
},
2026-10-05 14:15:34 +02:00
Measurement {
2026-10-05 14:18:58 +02:00
time_wall_clock: Time::new::<second>(2.3),
2026-10-06 13:34:03 +02:00
time_cpu: Time::new::<second>(2.3),
2026-10-05 14:18:58 +02:00
time_user: Time::new::<second>(2.3),
2026-10-05 14:17:14 +02:00
time_system: Time::zero(),
memory_peak_resident: Some(Information::new::<byte>(1024.)),
hardware_counters: Default::default(),
2026-10-05 14:16:20 +02:00
exit_status: ExitStatus::default(),
2026-10-05 12:46:10 +02:00
},
2026-10-05 14:15:02 +02:00
]),
2024-12-29 12:46:37 +01:00
parameters: BTreeMap::new(),
},
BenchmarkResult {
command: String::from("sleep 0.1"),
2026-10-05 18:11:10 +02:00
name: None,
2026-10-05 21:02:52 +02:00
display_name: String::from("sleep 0.1"),
2026-10-05 14:15:34 +02:00
measurements: Measurements::new(vec![
Measurement {
2026-10-05 14:18:58 +02:00
time_wall_clock: Time::new::<second>(0.1),
2026-10-06 13:34:03 +02:00
time_cpu: Time::new::<second>(0.1),
2026-10-05 14:18:58 +02:00
time_user: Time::new::<second>(0.1),
2026-10-05 14:17:14 +02:00
time_system: Time::zero(),
memory_peak_resident: Some(Information::new::<byte>(1024.)),
hardware_counters: Default::default(),
2026-10-05 14:16:20 +02:00
exit_status: ExitStatus::default(),
2026-10-05 12:46:10 +02:00
},
2026-10-05 14:15:34 +02:00
Measurement {
2026-10-05 14:18:58 +02:00
time_wall_clock: Time::new::<second>(0.2),
2026-10-06 13:34:03 +02:00
time_cpu: Time::new::<second>(0.2),
2026-10-05 14:18:58 +02:00
time_user: Time::new::<second>(0.2),
2026-10-05 14:17:14 +02:00
time_system: Time::zero(),
memory_peak_resident: Some(Information::new::<byte>(1024.)),
hardware_counters: Default::default(),
2026-10-05 14:16:20 +02:00
exit_status: ExitStatus::default(),
2026-10-05 12:46:10 +02:00
},
2026-10-05 14:15:34 +02:00
Measurement {
2026-10-05 14:18:58 +02:00
time_wall_clock: Time::new::<second>(0.3),
2026-10-06 13:34:03 +02:00
time_cpu: Time::new::<second>(0.3),
2026-10-05 14:18:58 +02:00
time_user: Time::new::<second>(0.3),
2026-10-05 14:17:14 +02:00
time_system: Time::zero(),
memory_peak_resident: Some(Information::new::<byte>(1024.)),
hardware_counters: Default::default(),
2026-10-05 14:16:20 +02:00
exit_status: ExitStatus::default(),
2026-10-05 12:46:10 +02:00
},
2026-10-05 14:15:02 +02:00
]),
2024-12-29 12:46:37 +01:00
parameters: BTreeMap::new(),
},
];
2026-10-06 10:52:49 +02:00
insta::assert_snapshot!(get_output::<MarkdownExporter>(&timing_results, Some(Unit { symbol: "ms", scale: 0.001 })), @"
| Command | Mean Wall Time [ms] | Min [ms] | Max [ms] | Change |
2024-12-29 12:46:37 +01:00
|:---|---:|---:|---:|---:|
| `sleep 2` | 2200.0 ± 100.0 | 2100.0 | 2300.0 | reference |
| `sleep 0.1` | 200.0 ± 100.0 | 100.0 | 300.0 | -90.9% |
2026-10-06 10:52:49 +02:00
");
2024-12-29 13:10:50 +01:00
insta::assert_snapshot!(get_output::<AsciidocExporter>(&timing_results, Some(Unit { symbol: "ms", scale: 0.001 })), @r#"
2024-12-29 13:10:50 +01:00
[cols="<,>,>,>,>"]
|===
| Command
2026-10-06 10:52:49 +02:00
| Mean Wall Time [ms]
| Min [ms]
| Max [ms]
| Change
2024-12-29 13:10:50 +01:00
| `sleep 2`
| 2200.0 ± 100.0
| 2100.0
| 2300.0
| reference
2024-12-29 13:10:50 +01:00
| `sleep 0.1`
| 200.0 ± 100.0
| 100.0
| 300.0
| -90.9%
2024-12-29 13:10:50 +01:00
|===
"#);
2026-10-06 10:52:49 +02:00
insta::assert_snapshot!(get_output::<OrgmodeExporter>(&timing_results, Some(Unit { symbol: "ms", scale: 0.001 })), @"
| Command | Mean Wall Time [ms] | Min [ms] | Max [ms] | Change |
2024-12-29 13:10:50 +01:00
|--+--+--+--+--|
| =sleep 2= | 2200.0 ± 100.0 | 2100.0 | 2300.0 | reference |
| =sleep 0.1= | 200.0 ± 100.0 | 100.0 | 300.0 | -90.9% |
2026-10-06 10:52:49 +02:00
");
2024-12-29 13:10:50 +01:00
}
/// The given time unit (s) is used to set the units for all entries.
#[test]
fn test_markup_export_manual_s() {
let results = [
BenchmarkResult {
command: String::from("sleep 2"),
2026-10-05 18:11:10 +02:00
name: None,
2026-10-05 21:02:52 +02:00
display_name: String::from("sleep 2"),
2026-10-05 14:15:34 +02:00
measurements: Measurements::new(vec![
Measurement {
2026-10-05 14:18:58 +02:00
time_wall_clock: Time::new::<second>(2.01),
2026-10-06 13:34:03 +02:00
time_cpu: Time::new::<second>(2.01),
2026-10-05 14:18:58 +02:00
time_user: Time::new::<second>(2.01),
2026-10-05 14:17:14 +02:00
time_system: Time::zero(),
memory_peak_resident: Some(Information::new::<byte>(1024.)),
hardware_counters: Default::default(),
2026-10-05 14:16:20 +02:00
exit_status: ExitStatus::default(),
2026-10-05 12:46:10 +02:00
},
2026-10-05 14:15:34 +02:00
Measurement {
2026-10-05 14:18:58 +02:00
time_wall_clock: Time::new::<second>(2.02),
2026-10-06 13:34:03 +02:00
time_cpu: Time::new::<second>(2.02),
2026-10-05 14:18:58 +02:00
time_user: Time::new::<second>(2.02),
2026-10-05 14:17:14 +02:00
time_system: Time::zero(),
memory_peak_resident: Some(Information::new::<byte>(1024.)),
hardware_counters: Default::default(),
2026-10-05 14:16:20 +02:00
exit_status: ExitStatus::default(),
2026-10-05 12:46:10 +02:00
},
2026-10-05 14:15:34 +02:00
Measurement {
2026-10-05 14:18:58 +02:00
time_wall_clock: Time::new::<second>(2.03),
2026-10-06 13:34:03 +02:00
time_cpu: Time::new::<second>(2.03),
2026-10-05 14:18:58 +02:00
time_user: Time::new::<second>(2.03),
2026-10-05 14:17:14 +02:00
time_system: Time::zero(),
memory_peak_resident: Some(Information::new::<byte>(1024.)),
hardware_counters: Default::default(),
2026-10-05 14:16:20 +02:00
exit_status: ExitStatus::default(),
2026-10-05 12:46:10 +02:00
},
2026-10-05 14:15:02 +02:00
]),
2024-12-29 13:10:50 +01:00
parameters: BTreeMap::new(),
},
BenchmarkResult {
command: String::from("sleep 0.1"),
2026-10-05 18:11:10 +02:00
name: None,
2026-10-05 21:02:52 +02:00
display_name: String::from("sleep 0.1"),
2026-10-05 14:15:34 +02:00
measurements: Measurements::new(vec![
Measurement {
2026-10-05 14:18:58 +02:00
time_wall_clock: Time::new::<second>(0.11),
2026-10-06 13:34:03 +02:00
time_cpu: Time::new::<second>(0.11),
2026-10-05 14:18:58 +02:00
time_user: Time::new::<second>(0.11),
2026-10-05 14:17:14 +02:00
time_system: Time::zero(),
memory_peak_resident: Some(Information::new::<byte>(1024.)),
hardware_counters: Default::default(),
2026-10-05 14:16:20 +02:00
exit_status: ExitStatus::default(),
2026-10-05 12:46:10 +02:00
},
2026-10-05 14:15:34 +02:00
Measurement {
2026-10-05 14:18:58 +02:00
time_wall_clock: Time::new::<second>(0.12),
2026-10-06 13:34:03 +02:00
time_cpu: Time::new::<second>(0.12),
2026-10-05 14:18:58 +02:00
time_user: Time::new::<second>(0.12),
2026-10-05 14:17:14 +02:00
time_system: Time::zero(),
memory_peak_resident: Some(Information::new::<byte>(1024.)),
hardware_counters: Default::default(),
2026-10-05 14:16:20 +02:00
exit_status: ExitStatus::default(),
2026-10-05 12:46:10 +02:00
},
2026-10-05 14:15:34 +02:00
Measurement {
2026-10-05 14:18:58 +02:00
time_wall_clock: Time::new::<second>(0.13),
2026-10-06 13:34:03 +02:00
time_cpu: Time::new::<second>(0.13),
2026-10-05 14:18:58 +02:00
time_user: Time::new::<second>(0.13),
2026-10-05 14:17:14 +02:00
time_system: Time::zero(),
memory_peak_resident: Some(Information::new::<byte>(1024.)),
hardware_counters: Default::default(),
2026-10-05 14:16:20 +02:00
exit_status: ExitStatus::default(),
2026-10-05 12:46:10 +02:00
},
2026-10-05 14:15:02 +02:00
]),
2024-12-29 13:10:50 +01:00
parameters: BTreeMap::new(),
},
];
2026-10-06 10:52:49 +02:00
insta::assert_snapshot!(get_output::<MarkdownExporter>(&results, Some(Unit { symbol: "s", scale: 1.0 })), @"
| Command | Mean Wall Time [s] | Min [s] | Max [s] | Change |
2026-10-05 12:46:10 +02:00
|:---|---:|---:|---:|---:|
| `sleep 2` | 2.020 ± 0.010 | 2.010 | 2.030 | reference |
| `sleep 0.1` | 0.120 ± 0.010 | 0.110 | 0.130 | -94.1% |
2026-10-06 10:52:49 +02:00
");
2024-12-29 13:10:50 +01:00
insta::assert_snapshot!(get_output::<AsciidocExporter>(&results, Some(Unit { symbol: "s", scale: 1.0 })), @r#"
2024-12-29 13:10:50 +01:00
[cols="<,>,>,>,>"]
|===
| Command
2026-10-06 10:52:49 +02:00
| Mean Wall Time [s]
| Min [s]
| Max [s]
| Change
2024-12-29 13:10:50 +01:00
| `sleep 2`
| 2.020 ± 0.010
| 2.010
| 2.030
| reference
2024-12-29 13:10:50 +01:00
| `sleep 0.1`
| 0.120 ± 0.010
| 0.110
| 0.130
| -94.1%
2024-12-29 13:10:50 +01:00
|===
"#);
2024-12-29 12:46:37 +01:00
}