mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-01 17:00:18 +00:00
Better defaults
This commit is contained in:
1 parent
908b33cc1d
commit
55dfe6722c
9 files changed
+144
-130
No files matched your search
+3
-2
@@ -57,8 +57,9 @@ fn build_command() -> Command {
|
||||
.default_value("default")
|
||||
.help("Metrics to display, in order. The first is used for non-JSON exports. \
|
||||
Compare all commands with the first command. Presets: default (wall-clock \
|
||||
time and peak RSS; wall-clock time only on Windows), all (all available \
|
||||
metrics, skipping unavailable measurements). Both presets use automatic \
|
||||
time and peak RSS; wall-clock time only on Windows), speed (wall-clock, user, \
|
||||
and system time), all (all available metrics, skipping unavailable \
|
||||
measurements). All presets use automatic \
|
||||
units with wall-clock time first; use a preset on its own. Metrics: time_wall_clock, \
|
||||
time_user, time_system, memory_peak_resident, cpu_cycles, instructions, \
|
||||
cache_references, cache_misses, branch_misses. Optional units: ns/us/ms/s/min/h \
|
||||
|
||||
+25
-25
@@ -100,18 +100,18 @@ fn test_markup_export_auto_ms() {
|
||||
},
|
||||
];
|
||||
|
||||
insta::assert_snapshot!(get_output::<MarkdownExporter>(&results, None), @r#"
|
||||
| Command | Mean Time [ms] | Min [ms] | Max [ms] | Change |
|
||||
insta::assert_snapshot!(get_output::<MarkdownExporter>(&results, None), @"
|
||||
| Command | Mean Wall Time [ms] | Min [ms] | Max [ms] | Change |
|
||||
|:---|---:|---:|---:|---:|
|
||||
| `sleep 0.1` | 110.0 ± 26.5 | 90.0 | 140.0 | reference |
|
||||
| `sleep 2` | 3000.0 ± 1000.0 | 2000.0 | 4000.0 | +2627.3% |
|
||||
"#);
|
||||
");
|
||||
|
||||
insta::assert_snapshot!(get_output::<AsciidocExporter>(&results, None), @r#"
|
||||
[cols="<,>,>,>,>"]
|
||||
|===
|
||||
| Command
|
||||
| Mean Time [ms]
|
||||
| Mean Wall Time [ms]
|
||||
| Min [ms]
|
||||
| Max [ms]
|
||||
| Change
|
||||
@@ -130,12 +130,12 @@ fn test_markup_export_auto_ms() {
|
||||
|===
|
||||
"#);
|
||||
|
||||
insta::assert_snapshot!(get_output::<OrgmodeExporter>(&results, None), @r#"
|
||||
| Command | Mean Time [ms] | Min [ms] | Max [ms] | Change |
|
||||
insta::assert_snapshot!(get_output::<OrgmodeExporter>(&results, None), @"
|
||||
| Command | Mean Wall Time [ms] | Min [ms] | Max [ms] | Change |
|
||||
|--+--+--+--+--|
|
||||
| =sleep 0.1= | 110.0 ± 26.5 | 90.0 | 140.0 | reference |
|
||||
| =sleep 2= | 3000.0 ± 1000.0 | 2000.0 | 4000.0 | +2627.3% |
|
||||
"#);
|
||||
");
|
||||
}
|
||||
|
||||
/// This (again) demonstrates that the first entry's units (s) are used to set
|
||||
@@ -209,18 +209,18 @@ fn test_markup_export_auto_s() {
|
||||
},
|
||||
];
|
||||
|
||||
insta::assert_snapshot!(get_output::<MarkdownExporter>(&results, None), @r#"
|
||||
| Command | Mean Time [s] | Min [s] | Max [s] | Change |
|
||||
insta::assert_snapshot!(get_output::<MarkdownExporter>(&results, None), @"
|
||||
| Command | Mean Wall Time [s] | Min [s] | Max [s] | Change |
|
||||
|:---|---:|---:|---:|---:|
|
||||
| `sleep 2` | 2.200 ± 0.100 | 2.100 | 2.300 | reference |
|
||||
| `sleep 0.1` | 0.200 ± 0.100 | 0.100 | 0.300 | -90.9% |
|
||||
"#);
|
||||
");
|
||||
|
||||
insta::assert_snapshot!(get_output::<AsciidocExporter>(&results, None), @r#"
|
||||
[cols="<,>,>,>,>"]
|
||||
|===
|
||||
| Command
|
||||
| Mean Time [s]
|
||||
| Mean Wall Time [s]
|
||||
| Min [s]
|
||||
| Max [s]
|
||||
| Change
|
||||
@@ -239,12 +239,12 @@ fn test_markup_export_auto_s() {
|
||||
|===
|
||||
"#);
|
||||
|
||||
insta::assert_snapshot!(get_output::<OrgmodeExporter>(&results, None), @r#"
|
||||
| Command | Mean Time [s] | Min [s] | Max [s] | Change |
|
||||
insta::assert_snapshot!(get_output::<OrgmodeExporter>(&results, None), @"
|
||||
| Command | Mean Wall Time [s] | Min [s] | Max [s] | Change |
|
||||
|--+--+--+--+--|
|
||||
| =sleep 2= | 2.200 ± 0.100 | 2.100 | 2.300 | reference |
|
||||
| =sleep 0.1= | 0.200 ± 0.100 | 0.100 | 0.300 | -90.9% |
|
||||
"#);
|
||||
");
|
||||
}
|
||||
|
||||
/// This (again) demonstrates that the given time unit (ms) is used to set
|
||||
@@ -318,18 +318,18 @@ fn test_markup_export_manual_ms() {
|
||||
},
|
||||
];
|
||||
|
||||
insta::assert_snapshot!(get_output::<MarkdownExporter>(&timing_results, Some(Unit { symbol: "ms", scale: 0.001 })), @r#"
|
||||
| Command | Mean Time [ms] | Min [ms] | Max [ms] | Change |
|
||||
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 |
|
||||
|:---|---:|---:|---:|---:|
|
||||
| `sleep 2` | 2200.0 ± 100.0 | 2100.0 | 2300.0 | reference |
|
||||
| `sleep 0.1` | 200.0 ± 100.0 | 100.0 | 300.0 | -90.9% |
|
||||
"#);
|
||||
");
|
||||
|
||||
insta::assert_snapshot!(get_output::<AsciidocExporter>(&timing_results, Some(Unit { symbol: "ms", scale: 0.001 })), @r#"
|
||||
[cols="<,>,>,>,>"]
|
||||
|===
|
||||
| Command
|
||||
| Mean Time [ms]
|
||||
| Mean Wall Time [ms]
|
||||
| Min [ms]
|
||||
| Max [ms]
|
||||
| Change
|
||||
@@ -348,12 +348,12 @@ fn test_markup_export_manual_ms() {
|
||||
|===
|
||||
"#);
|
||||
|
||||
insta::assert_snapshot!(get_output::<OrgmodeExporter>(&timing_results, Some(Unit { symbol: "ms", scale: 0.001 })), @r#"
|
||||
| Command | Mean Time [ms] | Min [ms] | Max [ms] | Change |
|
||||
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 |
|
||||
|--+--+--+--+--|
|
||||
| =sleep 2= | 2200.0 ± 100.0 | 2100.0 | 2300.0 | reference |
|
||||
| =sleep 0.1= | 200.0 ± 100.0 | 100.0 | 300.0 | -90.9% |
|
||||
"#);
|
||||
");
|
||||
}
|
||||
|
||||
/// The given time unit (s) is used to set the units for all entries.
|
||||
@@ -426,18 +426,18 @@ fn test_markup_export_manual_s() {
|
||||
},
|
||||
];
|
||||
|
||||
insta::assert_snapshot!(get_output::<MarkdownExporter>(&results, Some(Unit { symbol: "s", scale: 1.0 })), @r#"
|
||||
| Command | Mean Time [s] | Min [s] | Max [s] | Change |
|
||||
insta::assert_snapshot!(get_output::<MarkdownExporter>(&results, Some(Unit { symbol: "s", scale: 1.0 })), @"
|
||||
| Command | Mean Wall Time [s] | Min [s] | Max [s] | Change |
|
||||
|:---|---:|---:|---:|---:|
|
||||
| `sleep 2` | 2.020 ± 0.010 | 2.010 | 2.030 | reference |
|
||||
| `sleep 0.1` | 0.120 ± 0.010 | 0.110 | 0.130 | -94.1% |
|
||||
"#);
|
||||
");
|
||||
|
||||
insta::assert_snapshot!(get_output::<AsciidocExporter>(&results, Some(Unit { symbol: "s", scale: 1.0 })), @r#"
|
||||
[cols="<,>,>,>,>"]
|
||||
|===
|
||||
| Command
|
||||
| Mean Time [s]
|
||||
| Mean Wall Time [s]
|
||||
| Min [s]
|
||||
| Max [s]
|
||||
| Change
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ impl Metric {
|
||||
|
||||
pub fn label(self) -> &'static str {
|
||||
match self {
|
||||
Self::TimeWallClock => "Time",
|
||||
Self::TimeWallClock => "Wall Time",
|
||||
Self::TimeUser => "User time",
|
||||
Self::TimeSystem => "System time",
|
||||
Self::MemoryPeakResident => "Memory",
|
||||
|
||||
@@ -397,6 +397,11 @@ impl Options {
|
||||
|
||||
match matches.get_one::<String>("metrics").unwrap().as_str() {
|
||||
"default" => {}
|
||||
"speed" => {
|
||||
options.metrics = [Metric::TimeWallClock, Metric::TimeUser, Metric::TimeSystem]
|
||||
.map(|metric| MetricSelection { metric, unit: None })
|
||||
.to_vec();
|
||||
}
|
||||
"all" => {
|
||||
let shell = matches!(
|
||||
options.executor_kind,
|
||||
|
||||
+11
-8
@@ -157,13 +157,7 @@ pub fn print(
|
||||
} else {
|
||||
text.normal().to_string()
|
||||
}
|
||||
} else if column == 1 {
|
||||
if index == 1 {
|
||||
text.green().bold().to_string()
|
||||
} else {
|
||||
text.green().to_string()
|
||||
}
|
||||
} else if column == 2 {
|
||||
} else if column == 1 || column == 2 {
|
||||
text.green().to_string()
|
||||
} else if column == 3 {
|
||||
text.cyan().to_string()
|
||||
@@ -184,7 +178,16 @@ pub fn print(
|
||||
line.push_str(&" ".repeat(unit_padding));
|
||||
}
|
||||
}
|
||||
console_writeln!(stdout, " {}", line.trim_end())?;
|
||||
let line = line.trim_end();
|
||||
console_writeln!(
|
||||
stdout,
|
||||
" {}",
|
||||
if index == 1 {
|
||||
line.bold()
|
||||
} else {
|
||||
line.normal()
|
||||
}
|
||||
)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
Reference in new issue
Block a user