mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-12-03 21:31:03 +00:00
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7801abf7ca | ||
|
|
f12f3d9f86 | ||
|
|
327d5f4d91 | ||
|
|
975fe108c4 | ||
|
|
001dcce10e | ||
|
|
6447ab3a4e | ||
|
|
ae4c8073db | ||
|
|
57ef17cdcb | ||
|
|
8b6224059c | ||
|
|
b5a6860d96 |
No files matched your search
@@ -18,7 +18,7 @@ jobs:
|
|||||||
name: Extract crate metadata
|
name: Extract crate metadata
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
- name: Extract crate information
|
- name: Extract crate information
|
||||||
id: crate_metadata
|
id: crate_metadata
|
||||||
run: |
|
run: |
|
||||||
@@ -49,7 +49,7 @@ jobs:
|
|||||||
- uses: dtolnay/rust-toolchain@stable
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
with:
|
with:
|
||||||
components: rustfmt
|
components: rustfmt
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
- run: cargo fmt -- --check
|
- run: cargo fmt -- --check
|
||||||
|
|
||||||
min_version:
|
min_version:
|
||||||
@@ -58,7 +58,7 @@ jobs:
|
|||||||
needs: crate_metadata
|
needs: crate_metadata
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout source code
|
- name: Checkout source code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
- name: Install rust toolchain (v${{ needs.crate_metadata.outputs.msrv }})
|
- name: Install rust toolchain (v${{ needs.crate_metadata.outputs.msrv }})
|
||||||
uses: dtolnay/rust-toolchain@master
|
uses: dtolnay/rust-toolchain@master
|
||||||
@@ -94,7 +94,7 @@ jobs:
|
|||||||
BUILD_CMD: cargo
|
BUILD_CMD: cargo
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout source code
|
- name: Checkout source code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
- name: Install prerequisites
|
- name: Install prerequisites
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
# v1.20.0
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Add `--reference-name` option to give a meaningful name to the reference command, see #808 (@niklasdewally)
|
||||||
|
- The `--ignore-failure` option now supports a comma-separated list of exit codes to ignore (e.g., `--ignore-failure=1,2`), see #836 (@sharkdp)
|
||||||
|
- Python scripts: Add `--time-unit` option to `advanced_statistics.py` (@sharkdp)
|
||||||
|
- Python scripts: Add new `plot_benchmarks.py` script for plotting collections of benchmarks, see #806 (@marxin)
|
||||||
|
|
||||||
|
## Bugfixes
|
||||||
|
|
||||||
|
- Fix bug where naming individual commands with parameter scan was not working correctly, see #794 (@teofr)
|
||||||
|
|
||||||
|
## Other
|
||||||
|
|
||||||
|
- Restrict `cat` tests to Unix environments, see #776 and #777 (@ritvikos)
|
||||||
|
|
||||||
# v1.19.0
|
# v1.19.0
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|||||||
Generated
+376
-242
File diff suppressed because it is too large.
Load diff
+3
-3
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
|
|||||||
name = "hyperfine"
|
name = "hyperfine"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://github.com/sharkdp/hyperfine"
|
repository = "https://github.com/sharkdp/hyperfine"
|
||||||
version = "1.19.0"
|
version = "1.20.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
rust-version = "1.88.0"
|
rust-version = "1.88.0"
|
||||||
@@ -65,14 +65,14 @@ approx = "0.5"
|
|||||||
assert_cmd = "2.0"
|
assert_cmd = "2.0"
|
||||||
insta = { version = "1.41.1", features = ["yaml"] }
|
insta = { version = "1.41.1", features = ["yaml"] }
|
||||||
predicates = "3.1"
|
predicates = "3.1"
|
||||||
tempfile = "3.14"
|
tempfile = "3.23"
|
||||||
|
|
||||||
[profile.dev.package]
|
[profile.dev.package]
|
||||||
insta.opt-level = 3
|
insta.opt-level = 3
|
||||||
similar.opt-level = 3
|
similar.opt-level = 3
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
clap = "4.5.47"
|
clap = "4.5.48"
|
||||||
clap_complete = "4.2.1"
|
clap_complete = "4.2.1"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
|
|||||||
@@ -10,29 +10,6 @@ A command-line benchmarking tool.
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
### Sponsors
|
|
||||||
|
|
||||||
A special *thank you* goes to our biggest <a href="doc/sponsors.md">sponsors</a>:<br>
|
|
||||||
|
|
||||||
<a href="https://www.warp.dev/hyperfine">
|
|
||||||
<img src="doc/sponsors/warp-logo.png" width="200" alt="Warp">
|
|
||||||
<br>
|
|
||||||
<strong>Warp, the intelligent terminal</strong>
|
|
||||||
<br>
|
|
||||||
<sub>Available on MacOS, Linux, Windows</sub>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<a href="https://tuple.app/hyperfine">
|
|
||||||
<img src="doc/sponsors/tuple-logo.png" width="200" alt="Tuple">
|
|
||||||
<br>
|
|
||||||
<strong>Tuple, the premier screen sharing app for developers</strong>
|
|
||||||
<br>
|
|
||||||
<sub>Available for MacOS & Windows</sub>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
* Statistical analysis across multiple runs.
|
* Statistical analysis across multiple runs.
|
||||||
@@ -197,8 +174,8 @@ apt install hyperfine
|
|||||||
|
|
||||||
Alternatively, for the latest version, you can download the appropriate `.deb` package from the [Release page](https://github.com/sharkdp/hyperfine/releases) and install it via `dpkg`:
|
Alternatively, for the latest version, you can download the appropriate `.deb` package from the [Release page](https://github.com/sharkdp/hyperfine/releases) and install it via `dpkg`:
|
||||||
```
|
```
|
||||||
wget https://github.com/sharkdp/hyperfine/releases/download/v1.19.0/hyperfine_1.19.0_amd64.deb
|
wget https://github.com/sharkdp/hyperfine/releases/download/v1.20.0/hyperfine_1.20.0_amd64.deb
|
||||||
sudo dpkg -i hyperfine_1.19.0_amd64.deb
|
sudo dpkg -i hyperfine_1.20.0_amd64.deb
|
||||||
```
|
```
|
||||||
|
|
||||||
### On Fedora
|
### On Fedora
|
||||||
@@ -225,7 +202,7 @@ pacman -S hyperfine
|
|||||||
|
|
||||||
### On Debian Linux
|
### On Debian Linux
|
||||||
|
|
||||||
On Debian Linux, hyperfine can be installed [from the testing repositories](https://packages.debian.org/testing/main/hyperfine):
|
On Debian Linux, hyperfine can be installed [from the official repositories](https://packages.debian.org/hyperfine):
|
||||||
```
|
```
|
||||||
apt install hyperfine
|
apt install hyperfine
|
||||||
```
|
```
|
||||||
|
|||||||
+1
-1
@@ -131,7 +131,7 @@ Execute \fICMD\fP after the completion of all benchmarking runs for each individ
|
|||||||
command to be benchmarked. This is useful if the commands to be benchmarked
|
command to be benchmarked. This is useful if the commands to be benchmarked
|
||||||
produce artifacts that need to be cleaned up. It only runs once a series of
|
produce artifacts that need to be cleaned up. It only runs once a series of
|
||||||
benchmark runs, as opposed to \fB\-\-conclude\fR option which runs after
|
benchmark runs, as opposed to \fB\-\-conclude\fR option which runs after
|
||||||
ever run.
|
every run.
|
||||||
.HP
|
.HP
|
||||||
\fB\-P\fR, \fB\-\-parameter\-scan\fR \fIVAR\fP \fIMIN\fP \fIMAX\fP
|
\fB\-P\fR, \fB\-\-parameter\-scan\fR \fIVAR\fP \fIMIN\fP \fIMAX\fP
|
||||||
.IP
|
.IP
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
## Sponsors
|
|
||||||
|
|
||||||
`hyperfine` development is sponsored by many individuals and companies. Thank you very much!
|
|
||||||
|
|
||||||
Please note, that being sponsored does not affect the individuality of the `hyperfine`
|
|
||||||
project or affect the maintainers' actions in any way.
|
|
||||||
We remain impartial and continue to assess pull requests solely on merit - the
|
|
||||||
features added, bugs solved, and effect on the overall complexity of the code.
|
|
||||||
No issue will have a different priority based on sponsorship status of the
|
|
||||||
reporter.
|
|
||||||
|
|
||||||
Contributions from anybody are most welcomed.
|
|
||||||
|
|
||||||
If you want to see our biggest sponsors, check the top of [`README.md`](../README.md#sponsors).
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 14 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 130 KiB |
+36
-18
@@ -79,23 +79,41 @@ fn run_command_and_measure_common(
|
|||||||
let result = execute_and_measure(command)
|
let result = execute_and_measure(command)
|
||||||
.with_context(|| format!("Failed to run command '{command_name}'"))?;
|
.with_context(|| format!("Failed to run command '{command_name}'"))?;
|
||||||
|
|
||||||
if command_failure_action == CmdFailureAction::RaiseError && !result.status.success() {
|
if !result.status.success() {
|
||||||
let when = match iteration {
|
use crate::util::exit_code::extract_exit_code;
|
||||||
BenchmarkIteration::NonBenchmarkRun => "a non-benchmark run".to_string(),
|
|
||||||
BenchmarkIteration::Warmup(0) => "the first warmup run".to_string(),
|
|
||||||
BenchmarkIteration::Warmup(i) => format!("warmup iteration {i}"),
|
|
||||||
BenchmarkIteration::Benchmark(0) => "the first benchmark run".to_string(),
|
|
||||||
BenchmarkIteration::Benchmark(i) => format!("benchmark iteration {i}"),
|
|
||||||
};
|
|
||||||
bail!(
|
|
||||||
"{cause} in {when}. Use the '-i'/'--ignore-failure' option if you want to ignore this. \
|
|
||||||
Alternatively, use the '--show-output' option to debug what went wrong.",
|
|
||||||
cause=result.status.code().map_or(
|
|
||||||
"The process has been terminated by a signal".into(),
|
|
||||||
|c| format!("Command terminated with non-zero exit code {c}")
|
|
||||||
|
|
||||||
),
|
let should_fail = match command_failure_action {
|
||||||
);
|
CmdFailureAction::RaiseError => true,
|
||||||
|
CmdFailureAction::IgnoreAllFailures => false,
|
||||||
|
CmdFailureAction::IgnoreSpecificFailures(ref codes) => {
|
||||||
|
// Only fail if the exit code is not in the list of codes to ignore
|
||||||
|
if let Some(exit_code) = extract_exit_code(result.status) {
|
||||||
|
!codes.contains(&exit_code)
|
||||||
|
} else {
|
||||||
|
// If we can't extract an exit code, treat it as a failure
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if should_fail {
|
||||||
|
let when = match iteration {
|
||||||
|
BenchmarkIteration::NonBenchmarkRun => "a non-benchmark run".to_string(),
|
||||||
|
BenchmarkIteration::Warmup(0) => "the first warmup run".to_string(),
|
||||||
|
BenchmarkIteration::Warmup(i) => format!("warmup iteration {i}"),
|
||||||
|
BenchmarkIteration::Benchmark(0) => "the first benchmark run".to_string(),
|
||||||
|
BenchmarkIteration::Benchmark(i) => format!("benchmark iteration {i}"),
|
||||||
|
};
|
||||||
|
bail!(
|
||||||
|
"{cause} in {when}. Use the '-i'/'--ignore-failure' option if you want to ignore this. \
|
||||||
|
Alternatively, use the '--show-output' option to debug what went wrong.",
|
||||||
|
cause=result.status.code().map_or(
|
||||||
|
"The process has been terminated by a signal".into(),
|
||||||
|
|c| format!("Command terminated with non-zero exit code {c}")
|
||||||
|
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(result)
|
Ok(result)
|
||||||
@@ -122,7 +140,7 @@ impl Executor for RawExecutor<'_> {
|
|||||||
let result = run_command_and_measure_common(
|
let result = run_command_and_measure_common(
|
||||||
command.get_command()?,
|
command.get_command()?,
|
||||||
iteration,
|
iteration,
|
||||||
command_failure_action.unwrap_or(self.options.command_failure_action),
|
command_failure_action.unwrap_or_else(|| self.options.command_failure_action.clone()),
|
||||||
&self.options.command_input_policy,
|
&self.options.command_input_policy,
|
||||||
output_policy,
|
output_policy,
|
||||||
&command.get_command_line(),
|
&command.get_command_line(),
|
||||||
@@ -187,7 +205,7 @@ impl Executor for ShellExecutor<'_> {
|
|||||||
let mut result = run_command_and_measure_common(
|
let mut result = run_command_and_measure_common(
|
||||||
command_builder,
|
command_builder,
|
||||||
iteration,
|
iteration,
|
||||||
command_failure_action.unwrap_or(self.options.command_failure_action),
|
command_failure_action.unwrap_or_else(|| self.options.command_failure_action.clone()),
|
||||||
&self.options.command_input_policy,
|
&self.options.command_input_policy,
|
||||||
output_policy,
|
output_policy,
|
||||||
&command.get_command_line(),
|
&command.get_command_line(),
|
||||||
|
|||||||
+8
-2
@@ -226,9 +226,15 @@ fn build_command() -> Command {
|
|||||||
.arg(
|
.arg(
|
||||||
Arg::new("ignore-failure")
|
Arg::new("ignore-failure")
|
||||||
.long("ignore-failure")
|
.long("ignore-failure")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::Set)
|
||||||
|
.value_name("MODE")
|
||||||
|
.num_args(0..=1)
|
||||||
|
.default_missing_value("all-non-zero")
|
||||||
|
.require_equals(true)
|
||||||
.short('i')
|
.short('i')
|
||||||
.help("Ignore non-zero exit codes of the benchmarked programs."),
|
.help("Ignore failures of the benchmarked programs. Without a value or with \
|
||||||
|
'all-non-zero', all non-zero exit codes are ignored. You can also provide \
|
||||||
|
a comma-separated list of exit codes to ignore (e.g., --ignore-failure=1,2)."),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("style")
|
Arg::new("style")
|
||||||
|
|||||||
+21
-5
@@ -67,13 +67,16 @@ impl Shell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Action to take when an executed command fails.
|
/// Action to take when an executed command fails.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum CmdFailureAction {
|
pub enum CmdFailureAction {
|
||||||
/// Exit with an error message
|
/// Exit with an error message
|
||||||
RaiseError,
|
RaiseError,
|
||||||
|
|
||||||
/// Simply ignore the non-zero exit code
|
/// Ignore all non-zero exit codes
|
||||||
Ignore,
|
IgnoreAllFailures,
|
||||||
|
|
||||||
|
/// Ignore specific exit codes
|
||||||
|
IgnoreSpecificFailures(Vec<i32>),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Output style type option
|
/// Output style type option
|
||||||
@@ -415,8 +418,21 @@ impl Options {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if matches.get_flag("ignore-failure") {
|
if let Some(mode) = matches.get_one::<String>("ignore-failure") {
|
||||||
options.command_failure_action = CmdFailureAction::Ignore;
|
options.command_failure_action = match mode.as_str() {
|
||||||
|
"all-non-zero" | "" => CmdFailureAction::IgnoreAllFailures,
|
||||||
|
codes => {
|
||||||
|
let exit_codes: Result<Vec<i32>, _> = codes
|
||||||
|
.split(',')
|
||||||
|
.map(|s| {
|
||||||
|
s.trim()
|
||||||
|
.parse::<i32>()
|
||||||
|
.map_err(|e| OptionsError::IntParsingError("ignore-failure", e))
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
CmdFailureAction::IgnoreSpecificFailures(exit_codes?)
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
options.time_unit = match matches.get_one::<String>("time-unit").map(|s| s.as_str()) {
|
options.time_unit = match matches.get_one::<String>("time-unit").map(|s| s.as_str()) {
|
||||||
|
|||||||
+1
-3
@@ -1,9 +1,7 @@
|
|||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
use assert_cmd::cargo::CommandCargoExt;
|
|
||||||
|
|
||||||
pub fn hyperfine_raw_command() -> Command {
|
pub fn hyperfine_raw_command() -> Command {
|
||||||
let mut cmd = Command::cargo_bin("hyperfine").unwrap();
|
let mut cmd = Command::new(assert_cmd::cargo::cargo_bin!("hyperfine"));
|
||||||
cmd.current_dir("tests/");
|
cmd.current_dir("tests/");
|
||||||
cmd
|
cmd
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -277,6 +277,78 @@ fn can_run_failing_commands_with_ignore_failure_option() {
|
|||||||
.success();
|
.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[test]
|
||||||
|
fn can_ignore_specific_exit_codes() {
|
||||||
|
// Test that specifying exit code 1 ignores it
|
||||||
|
hyperfine()
|
||||||
|
.arg("--runs=1")
|
||||||
|
.arg("--ignore-failure=1")
|
||||||
|
.arg("exit 1")
|
||||||
|
.assert()
|
||||||
|
.success();
|
||||||
|
|
||||||
|
// Test that other exit codes still fail
|
||||||
|
hyperfine()
|
||||||
|
.arg("--runs=1")
|
||||||
|
.arg("--ignore-failure=1")
|
||||||
|
.arg("exit 2")
|
||||||
|
.assert()
|
||||||
|
.failure()
|
||||||
|
.stderr(predicate::str::contains(
|
||||||
|
"Command terminated with non-zero exit code 2",
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[test]
|
||||||
|
fn can_ignore_multiple_exit_codes() {
|
||||||
|
// Test that all specified exit codes are ignored
|
||||||
|
hyperfine()
|
||||||
|
.arg("--runs=1")
|
||||||
|
.arg("--ignore-failure=1,2,3")
|
||||||
|
.arg("exit 1")
|
||||||
|
.assert()
|
||||||
|
.success();
|
||||||
|
|
||||||
|
hyperfine()
|
||||||
|
.arg("--runs=1")
|
||||||
|
.arg("--ignore-failure=1,2,3")
|
||||||
|
.arg("exit 2")
|
||||||
|
.assert()
|
||||||
|
.success();
|
||||||
|
|
||||||
|
hyperfine()
|
||||||
|
.arg("--runs=1")
|
||||||
|
.arg("--ignore-failure=1,2,3")
|
||||||
|
.arg("exit 3")
|
||||||
|
.assert()
|
||||||
|
.success();
|
||||||
|
|
||||||
|
// Test that other exit codes still fail
|
||||||
|
hyperfine()
|
||||||
|
.arg("--runs=1")
|
||||||
|
.arg("--ignore-failure=1,2,3")
|
||||||
|
.arg("exit 4")
|
||||||
|
.assert()
|
||||||
|
.failure()
|
||||||
|
.stderr(predicate::str::contains(
|
||||||
|
"Command terminated with non-zero exit code 4",
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[test]
|
||||||
|
fn ignore_failure_with_all_non_zero() {
|
||||||
|
// Test explicit "all-non-zero" mode
|
||||||
|
hyperfine()
|
||||||
|
.arg("--runs=1")
|
||||||
|
.arg("--ignore-failure=all-non-zero")
|
||||||
|
.arg("exit 5")
|
||||||
|
.assert()
|
||||||
|
.success();
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn shows_output_of_benchmarked_command() {
|
fn shows_output_of_benchmarked_command() {
|
||||||
hyperfine()
|
hyperfine()
|
||||||
|
|||||||
Reference in new issue
Block a user