mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-27 18:30:55 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
715f8fc4c9 |
No files matched your search
@@ -1,10 +1,3 @@
|
|||||||
# Unreleased
|
|
||||||
|
|
||||||
## Breaking changes
|
|
||||||
|
|
||||||
- Execute commands directly by default (`--shell=none`). Use `-S` (an alias for `--shell=default`) to restore the previous behavior (`sh` on Unix, `cmd.exe` on Windows), or select a shell with `--shell <SHELL>`.
|
|
||||||
- Repurpose `-S` as an alias for `--shell=default`. It no longer accepts a shell argument; replace `-S <SHELL>` with `--shell <SHELL>`.
|
|
||||||
|
|
||||||
# v1.21.0
|
# v1.21.0
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|||||||
@@ -26,9 +26,8 @@ A command-line benchmarking tool.
|
|||||||
|
|
||||||
### Basic benchmarks
|
### Basic benchmarks
|
||||||
|
|
||||||
To run a benchmark, you can simply call `hyperfine <command>...`. Each argument is an executable
|
To run a benchmark, you can simply call `hyperfine <command>...`. The argument(s) can be any
|
||||||
and its arguments. Commands run directly by default; use `-S` for shell syntax such as
|
shell command. For example:
|
||||||
pipes, redirections, and wildcards. For example:
|
|
||||||
```sh
|
```sh
|
||||||
hyperfine 'sleep 0.3'
|
hyperfine 'sleep 0.3'
|
||||||
```
|
```
|
||||||
@@ -54,7 +53,7 @@ by disk caches and whether they are cold or warm.
|
|||||||
If you want to run the benchmark on a warm cache, you can use the `-w`/`--warmup` option to
|
If you want to run the benchmark on a warm cache, you can use the `-w`/`--warmup` option to
|
||||||
perform a certain number of program executions before the actual benchmark:
|
perform a certain number of program executions before the actual benchmark:
|
||||||
```sh
|
```sh
|
||||||
hyperfine -S --warmup 3 'grep -R TODO *'
|
hyperfine --warmup 3 'grep -R TODO *'
|
||||||
```
|
```
|
||||||
|
|
||||||
Conversely, if you want to run the benchmark for a cold cache, you can use the `-p`/`--prepare`
|
Conversely, if you want to run the benchmark for a cold cache, you can use the `-p`/`--prepare`
|
||||||
@@ -66,7 +65,7 @@ sync; echo 3 | sudo tee /proc/sys/vm/drop_caches
|
|||||||
To use this specific command with hyperfine, call `sudo -v` to temporarily gain sudo permissions
|
To use this specific command with hyperfine, call `sudo -v` to temporarily gain sudo permissions
|
||||||
and then call:
|
and then call:
|
||||||
```sh
|
```sh
|
||||||
hyperfine -S --prepare 'sync; echo 3 | sudo tee /proc/sys/vm/drop_caches' 'grep -R TODO *'
|
hyperfine --prepare 'sync; echo 3 | sudo tee /proc/sys/vm/drop_caches' 'grep -R TODO *'
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parameterized benchmarks
|
### Parameterized benchmarks
|
||||||
@@ -102,34 +101,28 @@ hyperfine \
|
|||||||
If you need a unique value for each individual run of a benchmark command, hyperfine also exposes
|
If you need a unique value for each individual run of a benchmark command, hyperfine also exposes
|
||||||
the zero-based `$HYPERFINE_ITERATION` environment variable inside the benchmarked command itself:
|
the zero-based `$HYPERFINE_ITERATION` environment variable inside the benchmarked command itself:
|
||||||
```sh
|
```sh
|
||||||
hyperfine -S 'my-command > output-${HYPERFINE_ITERATION}.log'
|
hyperfine 'my-command > output-${HYPERFINE_ITERATION}.log'
|
||||||
```
|
```
|
||||||
|
|
||||||
### Intermediate shell
|
### Intermediate shell
|
||||||
|
|
||||||
By default, commands are executed directly, without an intermediate shell (`--shell=none`).
|
By default, commands are executed using `sh` on Unix (resolved through `PATH`) or `cmd.exe` on Windows.
|
||||||
Arguments are split using shell-like quoting, so quoted arguments containing spaces are supported.
|
If you want to use a different shell, you can use the `-S, --shell <SHELL>` option:
|
||||||
Shell syntax such as pipes, redirections, environment-variable expansion, `*`, and `~` is not interpreted.
|
|
||||||
This avoids shell startup overhead and the noise from correcting for it, especially for fast commands
|
|
||||||
(< 5 ms).
|
|
||||||
|
|
||||||
To enable shell syntax, use `-S` (an alias for `--shell=default`). This selects `sh`
|
|
||||||
on Unix (resolved through `PATH`) or `cmd.exe` on Windows:
|
|
||||||
```sh
|
|
||||||
hyperfine -S 'sleep 0.1 && echo done'
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also select a specific shell with `--shell <SHELL>`:
|
|
||||||
```sh
|
```sh
|
||||||
hyperfine --shell zsh 'for i in {1..10000}; do echo test; done'
|
hyperfine --shell zsh 'for i in {1..10000}; do echo test; done'
|
||||||
```
|
```
|
||||||
|
|
||||||
The shell setting applies to all commands, including `--setup`, `--prepare`, `--conclude`, and `--cleanup`.
|
Note that hyperfine always *corrects for the shell spawning time*. To do this, it performs a calibration
|
||||||
If any of these commands need shell syntax, enable a shell explicitly.
|
procedure where it runs the shell with an empty command (multiple times), to measure the startup time
|
||||||
|
of the shell. It will then subtract this time from the total to show the actual time used by the command
|
||||||
|
in question.
|
||||||
|
|
||||||
When a shell is enabled, hyperfine *corrects for the shell spawning time*. It runs the shell with an
|
If you want to run a benchmark *without an intermediate shell*, you can use the `-N` or `--shell=none`
|
||||||
empty command multiple times to measure its startup time, then subtracts this time from each
|
option. This is helpful for very fast commands (< 5 ms) where the shell startup overhead correction would
|
||||||
measurement.
|
produce a significant amount of noise. Note that you cannot use shell syntax like `*` or `~` in this case.
|
||||||
|
```
|
||||||
|
hyperfine -N 'grep -R TODO /home/user'
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### Shell functions
|
### Shell functions
|
||||||
@@ -145,7 +138,7 @@ hyperfine --shell=bash my_function
|
|||||||
Otherwise, inline the function into the benchmarked command:
|
Otherwise, inline the function into the benchmarked command:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
hyperfine -S 'my_function() { sleep 1; }; my_function'
|
hyperfine 'my_function() { sleep 1; }; my_function'
|
||||||
```
|
```
|
||||||
|
|
||||||
### Exporting results
|
### Exporting results
|
||||||
|
|||||||
+7
-13
@@ -3,7 +3,7 @@
|
|||||||
hyperfine \- command\-line benchmarking tool
|
hyperfine \- command\-line benchmarking tool
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B hyperfine
|
.B hyperfine
|
||||||
.RB [ \-hVNS ]
|
.RB [ \-hVN ]
|
||||||
.RB [ \-\-ignore\-failure[=MODE] ]
|
.RB [ \-\-ignore\-failure[=MODE] ]
|
||||||
.RB [ \-\-warmup
|
.RB [ \-\-warmup
|
||||||
.IR NUM ]
|
.IR NUM ]
|
||||||
@@ -172,7 +172,7 @@ arithmetic.
|
|||||||
.RS
|
.RS
|
||||||
Example:
|
Example:
|
||||||
.RS
|
.RS
|
||||||
\fBhyperfine\fR \fB\-\-shell=bash\fR \fB\-P\fR size 0 3 'sleep $((2**{size}))'
|
\fBhyperfine\fR \fB\-P\fR size 0 3 'sleep $((2**{size}))'
|
||||||
.RE
|
.RE
|
||||||
.RE
|
.RE
|
||||||
.IP
|
.IP
|
||||||
@@ -212,20 +212,15 @@ This performs benchmarks for 'g++ \-O2 main.cpp' and 'clang++ \-O2 main.cpp'.
|
|||||||
The option can be specified multiple times to run benchmarks for all
|
The option can be specified multiple times to run benchmarks for all
|
||||||
possible parameter combinations.
|
possible parameter combinations.
|
||||||
.HP
|
.HP
|
||||||
\fB\-\-shell\fR \fISHELL\fP
|
\fB\-S\fR, \fB\-\-shell\fR \fISHELL\fP
|
||||||
.IP
|
.IP
|
||||||
Set the shell to use for executing commands (default: none). This can be
|
Set the shell to use for executing benchmarked commands. This can be
|
||||||
the name or the path to the shell executable, or a full command line
|
the name or the path to the shell executable, or a full command line
|
||||||
like "bash \fB\-\-norc\fR". It can also be set to "default" to explicitly
|
like "bash \fB\-\-norc\fR". It can also be set to "default" to explicitly
|
||||||
select the platform shell (sh on Unix, cmd.exe on Windows). Finally, this can also be
|
select the default shell on this platform. Finally, this can also be
|
||||||
set to "none" to disable the shell. In this case, commands will be
|
set to "none" to disable the shell. In this case, commands will be
|
||||||
executed directly. They can still have arguments, but more complex
|
executed directly. They can still have arguments, but more complex
|
||||||
things like "sleep 0.1; sleep 0.2" are not possible without a shell.
|
things like "sleep 0.1; sleep 0.2" are not possible without a shell.
|
||||||
This option also applies to setup, prepare, conclude, and cleanup commands.
|
|
||||||
.HP
|
|
||||||
\fB\-S\fR
|
|
||||||
.IP
|
|
||||||
An alias for '\-\-shell=default' (sh on Unix, cmd.exe on Windows).
|
|
||||||
.HP
|
.HP
|
||||||
\fB\-N\fR
|
\fB\-N\fR
|
||||||
.IP
|
.IP
|
||||||
@@ -336,8 +331,7 @@ Write the output to the given file.
|
|||||||
This option can be specified once for all commands or multiple times,
|
This option can be specified once for all commands or multiple times,
|
||||||
once for each command. Note: If you want to log the output of each and
|
once for each command. Note: If you want to log the output of each and
|
||||||
every iteration, you can use a shell redirection and the $HYPERFINE_ITERATION
|
every iteration, you can use a shell redirection and the $HYPERFINE_ITERATION
|
||||||
environment variable (requires \fB\-S\fR / \fB\-\-shell=default\fR):
|
environment variable: 'my-command > output-${HYPERFINE_ITERATION}.log'
|
||||||
'my-command > output-${HYPERFINE_ITERATION}.log'
|
|
||||||
.HP
|
.HP
|
||||||
\fB\-\-input\fR \fIWHERE\fP
|
\fB\-\-input\fR \fIWHERE\fP
|
||||||
.IP
|
.IP
|
||||||
@@ -383,7 +377,7 @@ Perform a benchmark of 'grep' with a warm disk cache by executing 3 runs up fron
|
|||||||
of the measurement:
|
of the measurement:
|
||||||
.RS
|
.RS
|
||||||
.nf
|
.nf
|
||||||
\fBhyperfine\fR \fB\-S\fR \fB\-\-warmup\fR 3 'grep -R TODO *'
|
\fBhyperfine\fR \fB\-\-warmup\fR 3 'grep -R TODO *'
|
||||||
.fi
|
.fi
|
||||||
.RE
|
.RE
|
||||||
.LP
|
.LP
|
||||||
|
|||||||
@@ -20,7 +20,10 @@ import pathlib
|
|||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
from plot_utils import METRICS, add_metric_argument, validate_metric
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description=__doc__)
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
add_metric_argument(parser)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"files", nargs="+", type=pathlib.Path, help="JSON files with benchmark results"
|
"files", nargs="+", type=pathlib.Path, help="JSON files with benchmark results"
|
||||||
)
|
)
|
||||||
@@ -31,27 +34,29 @@ parser.add_argument(
|
|||||||
parser.add_argument("-o", "--output", help="Save image to the given filename")
|
parser.add_argument("-o", "--output", help="Save image to the given filename")
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
metric_label, metric_scale = METRICS[args.metric]
|
||||||
|
|
||||||
commands = None
|
commands = None
|
||||||
data = []
|
data = []
|
||||||
inputs = []
|
inputs = []
|
||||||
|
|
||||||
if args.benchmark_names:
|
if args.benchmark_names:
|
||||||
assert len(args.files) == len(
|
assert len(args.files) == len(args.benchmark_names), (
|
||||||
args.benchmark_names
|
"Number of benchmark names must match the number of input files."
|
||||||
), "Number of benchmark names must match the number of input files."
|
)
|
||||||
|
|
||||||
for i, filename in enumerate(args.files):
|
for i, filename in enumerate(args.files):
|
||||||
with open(filename) as f:
|
with open(filename) as f:
|
||||||
results = json.load(f)["results"]
|
results = json.load(f)["results"]
|
||||||
|
validate_metric(parser, results, args.metric)
|
||||||
benchmark_commands = [b.get("name", b["command"]) for b in results]
|
benchmark_commands = [b.get("name", b["command"]) for b in results]
|
||||||
if commands is None:
|
if commands is None:
|
||||||
commands = benchmark_commands
|
commands = benchmark_commands
|
||||||
else:
|
else:
|
||||||
assert (
|
assert commands == benchmark_commands, (
|
||||||
commands == benchmark_commands
|
f"Unexpected commands in {filename}: {benchmark_commands}, expected: {commands}"
|
||||||
), f"Unexpected commands in {filename}: {benchmark_commands}, expected: {commands}"
|
)
|
||||||
data.append([b["summary"]["time_wall_clock"]["mean"] for b in results])
|
data.append([b["summary"][args.metric]["mean"] / metric_scale for b in results])
|
||||||
if args.benchmark_names:
|
if args.benchmark_names:
|
||||||
inputs.append(args.benchmark_names[i])
|
inputs.append(args.benchmark_names[i])
|
||||||
else:
|
else:
|
||||||
@@ -74,7 +79,7 @@ ax.grid(visible=True, axis="y")
|
|||||||
if args.title:
|
if args.title:
|
||||||
plt.title(args.title)
|
plt.title(args.title)
|
||||||
plt.xlabel("Benchmark")
|
plt.xlabel("Benchmark")
|
||||||
plt.ylabel("Time [s]")
|
plt.ylabel(metric_label)
|
||||||
plt.legend(title="Command")
|
plt.legend(title="Command")
|
||||||
|
|
||||||
if args.output:
|
if args.output:
|
||||||
|
|||||||
@@ -16,7 +16,10 @@ import json
|
|||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
from plot_utils import METRICS, add_metric_argument, validate_metric
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description=__doc__)
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
add_metric_argument(parser)
|
||||||
parser.add_argument("file", help="JSON file with benchmark results")
|
parser.add_argument("file", help="JSON file with benchmark results")
|
||||||
parser.add_argument("--title", help="Plot title")
|
parser.add_argument("--title", help="Plot title")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
@@ -47,10 +50,18 @@ parser.add_argument(
|
|||||||
)
|
)
|
||||||
parser.add_argument("-o", "--output", help="Save image to the given filename.")
|
parser.add_argument("-o", "--output", help="Save image to the given filename.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--t-min", metavar="T", help="Minimum time to be displayed (seconds)"
|
"--min",
|
||||||
|
"--t-min",
|
||||||
|
dest="value_min",
|
||||||
|
type=float,
|
||||||
|
help="Minimum value to display (seconds, or MiB for memory)",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--t-max", metavar="T", help="Maximum time to be displayed (seconds)"
|
"--max",
|
||||||
|
"--t-max",
|
||||||
|
dest="value_max",
|
||||||
|
type=float,
|
||||||
|
help="Maximum value to display (seconds, or MiB for memory)",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--log-count",
|
"--log-count",
|
||||||
@@ -59,31 +70,41 @@ parser.add_argument(
|
|||||||
)
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
metric_label, metric_scale = METRICS[args.metric]
|
||||||
|
|
||||||
with open(args.file) as f:
|
with open(args.file) as f:
|
||||||
results = json.load(f)["results"]
|
results = json.load(f)["results"]
|
||||||
|
validate_metric(parser, results, args.metric)
|
||||||
|
|
||||||
if args.labels:
|
if args.labels:
|
||||||
labels = args.labels.split(",")
|
labels = args.labels.split(",")
|
||||||
else:
|
else:
|
||||||
labels = [b.get("name", b["command"]) for b in results]
|
labels = [b.get("name", b["command"]) for b in results]
|
||||||
all_times = [
|
all_values = [
|
||||||
[m["time_wall_clock"]["value"] for m in b["measurements"]] for b in results
|
[m[args.metric]["value"] / metric_scale for m in b["measurements"]] for b in results
|
||||||
]
|
]
|
||||||
|
|
||||||
t_min = float(args.t_min) if args.t_min else np.min(list(map(np.min, all_times)))
|
value_min = (
|
||||||
t_max = float(args.t_max) if args.t_max else np.max(list(map(np.max, all_times)))
|
args.value_min
|
||||||
|
if args.value_min is not None
|
||||||
|
else np.min(list(map(np.min, all_values)))
|
||||||
|
)
|
||||||
|
value_max = (
|
||||||
|
args.value_max
|
||||||
|
if args.value_max is not None
|
||||||
|
else np.max(list(map(np.max, all_values)))
|
||||||
|
)
|
||||||
|
|
||||||
bins = int(args.bins) if args.bins else "auto"
|
bins = int(args.bins) if args.bins else "auto"
|
||||||
histtype = args.type if args.type else "bar"
|
histtype = args.type if args.type else "bar"
|
||||||
|
|
||||||
plt.figure(figsize=(10, 5))
|
plt.figure(figsize=(10, 5))
|
||||||
plt.hist(
|
plt.hist(
|
||||||
all_times,
|
all_values,
|
||||||
label=labels,
|
label=labels,
|
||||||
bins=bins,
|
bins=bins,
|
||||||
histtype=histtype,
|
histtype=histtype,
|
||||||
range=(t_min, t_max),
|
range=(value_min, value_max),
|
||||||
)
|
)
|
||||||
plt.legend(
|
plt.legend(
|
||||||
loc=args.legend_location,
|
loc=args.legend_location,
|
||||||
@@ -92,7 +113,7 @@ plt.legend(
|
|||||||
prop={"size": 10, "family": ["Source Code Pro", "Fira Mono", "Courier New"]},
|
prop={"size": 10, "family": ["Source Code Pro", "Fira Mono", "Courier New"]},
|
||||||
)
|
)
|
||||||
|
|
||||||
plt.xlabel("Time [s]")
|
plt.xlabel(metric_label)
|
||||||
if args.title:
|
if args.title:
|
||||||
plt.title(args.title)
|
plt.title(args.title)
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,10 @@ import sys
|
|||||||
|
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
from plot_utils import METRICS, add_metric_argument, validate_metric
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description=__doc__)
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
add_metric_argument(parser)
|
||||||
parser.add_argument("file", help="JSON file with benchmark results", nargs="+")
|
parser.add_argument("file", help="JSON file with benchmark results", nargs="+")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--parameter-name",
|
"--parameter-name",
|
||||||
@@ -28,7 +31,11 @@ parser.add_argument(
|
|||||||
"--log-x", help="Use a logarithmic x (parameter) axis", action="store_true"
|
"--log-x", help="Use a logarithmic x (parameter) axis", action="store_true"
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--log-time", help="Use a logarithmic time axis", action="store_true"
|
"--log-y",
|
||||||
|
"--log-time",
|
||||||
|
dest="log_y",
|
||||||
|
help="Use a logarithmic metric axis",
|
||||||
|
action="store_true",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--titles", help="Comma-separated list of titles for the plot legend"
|
"--titles", help="Comma-separated list of titles for the plot legend"
|
||||||
@@ -36,6 +43,7 @@ parser.add_argument(
|
|||||||
parser.add_argument("-o", "--output", help="Save image to the given filename.")
|
parser.add_argument("-o", "--output", help="Save image to the given filename.")
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
metric_label, metric_scale = METRICS[args.metric]
|
||||||
if args.parameter_name is not None:
|
if args.parameter_name is not None:
|
||||||
sys.stderr.write(
|
sys.stderr.write(
|
||||||
"warning: --parameter-name is deprecated; names are inferred from "
|
"warning: --parameter-name is deprecated; names are inferred from "
|
||||||
@@ -79,6 +87,7 @@ parameter_name = None
|
|||||||
for filename in args.file:
|
for filename in args.file:
|
||||||
with open(filename) as f:
|
with open(filename) as f:
|
||||||
results = json.load(f)["results"]
|
results = json.load(f)["results"]
|
||||||
|
validate_metric(parser, results, args.metric)
|
||||||
|
|
||||||
(this_parameter_name, parameter_values) = extract_parameters(results)
|
(this_parameter_name, parameter_values) = extract_parameters(results)
|
||||||
if parameter_name is not None and this_parameter_name != parameter_name:
|
if parameter_name is not None and this_parameter_name != parameter_name:
|
||||||
@@ -87,18 +96,19 @@ for filename in args.file:
|
|||||||
)
|
)
|
||||||
parameter_name = this_parameter_name
|
parameter_name = this_parameter_name
|
||||||
|
|
||||||
summaries = [b["summary"]["time_wall_clock"] for b in results]
|
summaries = [b["summary"][args.metric] for b in results]
|
||||||
times_mean = [s["mean"] for s in summaries]
|
means = [s["mean"] / metric_scale for s in summaries]
|
||||||
times_stddev = [
|
stddevs = [
|
||||||
s["stddev"] if s["stddev"] is not None else float("nan") for s in summaries
|
s["stddev"] / metric_scale if s["stddev"] is not None else float("nan")
|
||||||
|
for s in summaries
|
||||||
]
|
]
|
||||||
|
|
||||||
plt.errorbar(x=parameter_values, y=times_mean, yerr=times_stddev, capsize=2)
|
plt.errorbar(x=parameter_values, y=means, yerr=stddevs, capsize=2)
|
||||||
|
|
||||||
plt.xlabel(parameter_name)
|
plt.xlabel(parameter_name)
|
||||||
plt.ylabel("Time [s]")
|
plt.ylabel(metric_label)
|
||||||
|
|
||||||
if args.log_time:
|
if args.log_y:
|
||||||
plt.yscale("log")
|
plt.yscale("log")
|
||||||
else:
|
else:
|
||||||
plt.ylim(0, None)
|
plt.ylim(0, None)
|
||||||
|
|||||||
@@ -19,16 +19,19 @@ import json
|
|||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
from plot_utils import METRICS, add_metric_argument, validate_metric
|
||||||
|
|
||||||
def moving_average(times, num_runs):
|
|
||||||
times_padded = np.pad(
|
def moving_average(values, num_runs):
|
||||||
times, (num_runs // 2, num_runs - 1 - num_runs // 2), mode="edge"
|
values_padded = np.pad(
|
||||||
|
values, (num_runs // 2, num_runs - 1 - num_runs // 2), mode="edge"
|
||||||
)
|
)
|
||||||
kernel = np.ones(num_runs) / num_runs
|
kernel = np.ones(num_runs) / num_runs
|
||||||
return np.convolve(times_padded, kernel, mode="valid")
|
return np.convolve(values_padded, kernel, mode="valid")
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description=__doc__)
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
add_metric_argument(parser)
|
||||||
parser.add_argument("file", help="JSON file with benchmark results")
|
parser.add_argument("file", help="JSON file with benchmark results")
|
||||||
parser.add_argument("--title", help="Plot Title")
|
parser.add_argument("--title", help="Plot Title")
|
||||||
parser.add_argument("-o", "--output", help="Save image to the given filename.")
|
parser.add_argument("-o", "--output", help="Save image to the given filename.")
|
||||||
@@ -47,17 +50,19 @@ parser.add_argument(
|
|||||||
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
metric_label, metric_scale = METRICS[args.metric]
|
||||||
|
|
||||||
with open(args.file) as f:
|
with open(args.file) as f:
|
||||||
results = json.load(f)["results"]
|
results = json.load(f)["results"]
|
||||||
|
validate_metric(parser, results, args.metric)
|
||||||
|
|
||||||
for result in results:
|
for result in results:
|
||||||
label = result.get("name", result["command"])
|
label = result.get("name", result["command"])
|
||||||
times = [m["time_wall_clock"]["value"] for m in result["measurements"]]
|
values = [m[args.metric]["value"] / metric_scale for m in result["measurements"]]
|
||||||
num = len(times)
|
num = len(values)
|
||||||
nums = range(num)
|
nums = range(num)
|
||||||
|
|
||||||
plt.scatter(x=nums, y=times, marker=".")
|
plt.scatter(x=nums, y=values, marker=".")
|
||||||
plt.ylim([0, None])
|
plt.ylim([0, None])
|
||||||
plt.xlim([-1, num])
|
plt.xlim([-1, num])
|
||||||
|
|
||||||
@@ -68,7 +73,7 @@ for result in results:
|
|||||||
else args.moving_average_width
|
else args.moving_average_width
|
||||||
)
|
)
|
||||||
|
|
||||||
average = moving_average(times, moving_average_width)
|
average = moving_average(values, moving_average_width)
|
||||||
plt.plot(nums, average, "-")
|
plt.plot(nums, average, "-")
|
||||||
|
|
||||||
if args.title:
|
if args.title:
|
||||||
@@ -81,7 +86,7 @@ for result in results:
|
|||||||
legend.append("moving average")
|
legend.append("moving average")
|
||||||
plt.legend(legend)
|
plt.legend(legend)
|
||||||
|
|
||||||
plt.ylabel("Time [s]")
|
plt.ylabel(metric_label)
|
||||||
|
|
||||||
if args.output:
|
if args.output:
|
||||||
plt.savefig(args.output)
|
plt.savefig(args.output)
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
"""Shared metric options for the plotting scripts."""
|
||||||
|
|
||||||
|
METRICS = {
|
||||||
|
"time_wall_clock": ("Time [s]", 1),
|
||||||
|
"time_user": ("User CPU time [s]", 1),
|
||||||
|
"time_system": ("System CPU time [s]", 1),
|
||||||
|
"memory_peak_resident": ("Peak resident memory [MiB]", 1024**2),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def add_metric_argument(parser):
|
||||||
|
parser.add_argument(
|
||||||
|
"--metric",
|
||||||
|
choices=METRICS,
|
||||||
|
default="time_wall_clock",
|
||||||
|
help="Metric to plot (default: time_wall_clock). "
|
||||||
|
"Times are in seconds; memory is in MiB.",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def validate_metric(parser, results, metric):
|
||||||
|
for result in results:
|
||||||
|
if metric not in result["summary"]:
|
||||||
|
parser.error(
|
||||||
|
f"metric {metric!r} is unavailable for "
|
||||||
|
f"{result.get('name', result['command'])!r}"
|
||||||
|
)
|
||||||
+13
-6
@@ -20,7 +20,10 @@ import json
|
|||||||
|
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
from plot_utils import METRICS, add_metric_argument, validate_metric
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description=__doc__)
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
add_metric_argument(parser)
|
||||||
parser.add_argument("file", help="JSON file with benchmark results")
|
parser.add_argument("file", help="JSON file with benchmark results")
|
||||||
parser.add_argument("--title", help="Plot Title")
|
parser.add_argument("--title", help="Plot Title")
|
||||||
parser.add_argument("--sort-by", choices=["median"], help="Sort method")
|
parser.add_argument("--sort-by", choices=["median"], help="Sort method")
|
||||||
@@ -30,26 +33,30 @@ parser.add_argument(
|
|||||||
parser.add_argument("-o", "--output", help="Save image to the given filename.")
|
parser.add_argument("-o", "--output", help="Save image to the given filename.")
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
metric_label, metric_scale = METRICS[args.metric]
|
||||||
|
|
||||||
with open(args.file, encoding="utf-8") as f:
|
with open(args.file, encoding="utf-8") as f:
|
||||||
results = json.load(f)["results"]
|
results = json.load(f)["results"]
|
||||||
|
validate_metric(parser, results, args.metric)
|
||||||
|
|
||||||
if args.labels:
|
if args.labels:
|
||||||
labels = args.labels.split(",")
|
labels = args.labels.split(",")
|
||||||
else:
|
else:
|
||||||
labels = [b.get("name", b["command"]) for b in results]
|
labels = [b.get("name", b["command"]) for b in results]
|
||||||
times = [[m["time_wall_clock"]["value"] for m in b["measurements"]] for b in results]
|
values = [
|
||||||
|
[m[args.metric]["value"] / metric_scale for m in b["measurements"]] for b in results
|
||||||
|
]
|
||||||
|
|
||||||
if args.sort_by == "median":
|
if args.sort_by == "median":
|
||||||
medians = [b["summary"]["time_wall_clock"]["median"] for b in results]
|
medians = [b["summary"][args.metric]["median"] for b in results]
|
||||||
indices = sorted(range(len(labels)), key=lambda k: medians[k])
|
indices = sorted(range(len(labels)), key=lambda k: medians[k])
|
||||||
labels = [labels[i] for i in indices]
|
labels = [labels[i] for i in indices]
|
||||||
times = [times[i] for i in indices]
|
values = [values[i] for i in indices]
|
||||||
|
|
||||||
plt.figure(figsize=(10, 6), constrained_layout=True)
|
plt.figure(figsize=(10, 6), constrained_layout=True)
|
||||||
boxplot = plt.boxplot(times, vert=True, patch_artist=True)
|
boxplot = plt.boxplot(values, vert=True, patch_artist=True)
|
||||||
cmap = plt.get_cmap("rainbow")
|
cmap = plt.get_cmap("rainbow")
|
||||||
colors = [cmap(val / len(times)) for val in range(len(times))]
|
colors = [cmap(val / len(values)) for val in range(len(values))]
|
||||||
|
|
||||||
for patch, color in zip(boxplot["boxes"], colors):
|
for patch, color in zip(boxplot["boxes"], colors):
|
||||||
patch.set_facecolor(color)
|
patch.set_facecolor(color)
|
||||||
@@ -57,7 +64,7 @@ for patch, color in zip(boxplot["boxes"], colors):
|
|||||||
if args.title:
|
if args.title:
|
||||||
plt.title(args.title)
|
plt.title(args.title)
|
||||||
plt.legend(handles=boxplot["boxes"], labels=labels, loc="best", fontsize="medium")
|
plt.legend(handles=boxplot["boxes"], labels=labels, loc="best", fontsize="medium")
|
||||||
plt.ylabel("Time [s]")
|
plt.ylabel(metric_label)
|
||||||
plt.ylim(0, None)
|
plt.ylim(0, None)
|
||||||
plt.xticks(list(range(1, len(labels) + 1)), labels, rotation=45)
|
plt.xticks(list(range(1, len(labels) + 1)), labels, rotation=45)
|
||||||
if args.output:
|
if args.output:
|
||||||
|
|||||||
+8
-15
@@ -36,8 +36,8 @@ fn build_command() -> Command {
|
|||||||
Arg::new("command")
|
Arg::new("command")
|
||||||
.help("The command to benchmark. This can be the name of an executable, a command \
|
.help("The command to benchmark. This can be the name of an executable, a command \
|
||||||
line like \"grep -i todo\" or a shell command like \"sleep 0.5 && echo test\". \
|
line like \"grep -i todo\" or a shell command like \"sleep 0.5 && echo test\". \
|
||||||
The latter requires a shell, which can be enabled via '-S' or '--shell=...'. \
|
The latter is only available if the shell is not explicitly disabled via \
|
||||||
If multiple commands are given, hyperfine will show a \
|
'--shell=none'. If multiple commands are given, hyperfine will show a \
|
||||||
comparison of the respective runtimes.")
|
comparison of the respective runtimes.")
|
||||||
.required(true)
|
.required(true)
|
||||||
.action(ArgAction::Append)
|
.action(ArgAction::Append)
|
||||||
@@ -181,7 +181,7 @@ fn build_command() -> Command {
|
|||||||
Example: hyperfine --prepare 'make clean' -P threads 1 8 'make -j {threads}'\n\n\
|
Example: hyperfine --prepare 'make clean' -P threads 1 8 'make -j {threads}'\n\n\
|
||||||
This performs benchmarks for 'make -j 1', 'make -j 2', …, 'make -j 8'.\n\n\
|
This performs benchmarks for 'make -j 1', 'make -j 2', …, 'make -j 8'.\n\n\
|
||||||
To have the value increase following different patterns, use shell arithmetic.\n\n \
|
To have the value increase following different patterns, use shell arithmetic.\n\n \
|
||||||
Example: hyperfine --shell=bash -P size 0 3 'sleep $((2**{size}))'\n\n\
|
Example: hyperfine -P size 0 3 'sleep $((2**{size}))'\n\n\
|
||||||
This performs benchmarks with power of 2 increases: 'sleep 1', 'sleep 2', 'sleep 4', …\n\
|
This performs benchmarks with power of 2 increases: 'sleep 1', 'sleep 2', 'sleep 4', …\n\
|
||||||
The exact syntax may vary depending on your shell and OS."
|
The exact syntax may vary depending on your shell and OS."
|
||||||
),
|
),
|
||||||
@@ -220,25 +220,18 @@ fn build_command() -> Command {
|
|||||||
.arg(
|
.arg(
|
||||||
Arg::new("shell")
|
Arg::new("shell")
|
||||||
.long("shell")
|
.long("shell")
|
||||||
|
.short('S')
|
||||||
.action(ArgAction::Set)
|
.action(ArgAction::Set)
|
||||||
.value_name("SHELL")
|
.value_name("SHELL")
|
||||||
.overrides_with("shell")
|
.overrides_with("shell")
|
||||||
.value_hint(ValueHint::CommandString)
|
.value_hint(ValueHint::CommandString)
|
||||||
.help("Set the shell to use for executing commands (default: none). This can be the \
|
.help("Set the shell to use for executing benchmarked commands. This can be the \
|
||||||
name or the path to the shell executable, or a full command line \
|
name or the path to the shell executable, or a full command line \
|
||||||
like \"bash --norc\". It can also be set to \"default\" to explicitly select \
|
like \"bash --norc\". It can also be set to \"default\" to explicitly select \
|
||||||
the platform shell (sh on Unix, cmd.exe on Windows). It can also be set to \
|
the default shell on this platform. Finally, this can also be set to \
|
||||||
\"none\" to disable the shell. In this case, commands will be executed \
|
\"none\" to disable the shell. In this case, commands will be executed \
|
||||||
directly. They can still have arguments, but more complex things like \
|
directly. They can still have arguments, but more complex things like \
|
||||||
\"sleep 0.1; sleep 0.2\" are not possible without a shell. This option also \
|
\"sleep 0.1; sleep 0.2\" are not possible without a shell.")
|
||||||
applies to setup, prepare, conclude, and cleanup commands.")
|
|
||||||
)
|
|
||||||
.arg(
|
|
||||||
Arg::new("default-shell")
|
|
||||||
.short('S')
|
|
||||||
.action(ArgAction::SetTrue)
|
|
||||||
.conflicts_with_all(["shell", "no-shell", "debug-mode"])
|
|
||||||
.help("An alias for '--shell=default' (sh on Unix, cmd.exe on Windows).")
|
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("no-shell")
|
Arg::new("no-shell")
|
||||||
@@ -390,7 +383,7 @@ fn build_command() -> Command {
|
|||||||
This option can be specified once for all commands or multiple times, once for \
|
This option can be specified once for all commands or multiple times, once for \
|
||||||
each command. Note: If you want to log the output of each and every iteration, \
|
each command. Note: If you want to log the output of each and every iteration, \
|
||||||
you can use a shell redirection and the '$HYPERFINE_ITERATION' environment variable:\n \
|
you can use a shell redirection and the '$HYPERFINE_ITERATION' environment variable:\n \
|
||||||
hyperfine -S 'my-command > output-${HYPERFINE_ITERATION}.log'\n\n",
|
hyperfine 'my-command > output-${HYPERFINE_ITERATION}.log'\n\n",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
|
|||||||
+17
-15
@@ -29,6 +29,12 @@ pub enum Shell {
|
|||||||
Custom(Vec<String>),
|
Custom(Vec<String>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for Shell {
|
||||||
|
fn default() -> Self {
|
||||||
|
Shell::Default(DEFAULT_SHELL)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl fmt::Display for Shell {
|
impl fmt::Display for Shell {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
@@ -39,11 +45,6 @@ impl fmt::Display for Shell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Shell {
|
impl Shell {
|
||||||
/// Select the platform shell (sh on Unix, cmd.exe on Windows).
|
|
||||||
pub fn platform_default() -> Self {
|
|
||||||
Shell::Default(DEFAULT_SHELL)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Parse given string as shell command line
|
/// Parse given string as shell command line
|
||||||
pub fn parse_from_str<'a>(s: &str) -> Result<Self, OptionsError<'a>> {
|
pub fn parse_from_str<'a>(s: &str) -> Result<Self, OptionsError<'a>> {
|
||||||
let v = shell_words::split(s).map_err(OptionsError::ShellParseError)?;
|
let v = shell_words::split(s).map_err(OptionsError::ShellParseError)?;
|
||||||
@@ -180,14 +181,19 @@ impl CommandOutputPolicy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum ExecutorKind {
|
pub enum ExecutorKind {
|
||||||
#[default]
|
|
||||||
Raw,
|
Raw,
|
||||||
Shell(Shell),
|
Shell(Shell),
|
||||||
Mock(Option<String>),
|
Mock(Option<String>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for ExecutorKind {
|
||||||
|
fn default() -> Self {
|
||||||
|
ExecutorKind::Shell(Shell::default())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The main settings for a hyperfine benchmark session
|
/// The main settings for a hyperfine benchmark session
|
||||||
pub struct Options {
|
pub struct Options {
|
||||||
/// Upper and lower bound for the number of benchmark runs
|
/// Upper and lower bound for the number of benchmark runs
|
||||||
@@ -395,19 +401,15 @@ impl Options {
|
|||||||
|
|
||||||
options.executor_kind = if matches.get_flag("no-shell") {
|
options.executor_kind = if matches.get_flag("no-shell") {
|
||||||
ExecutorKind::Raw
|
ExecutorKind::Raw
|
||||||
} else if matches.get_flag("default-shell") {
|
|
||||||
ExecutorKind::Shell(Shell::platform_default())
|
|
||||||
} else {
|
} else {
|
||||||
match (
|
match (
|
||||||
matches.get_flag("debug-mode"),
|
matches.get_flag("debug-mode"),
|
||||||
matches.get_one::<String>("shell"),
|
matches.get_one::<String>("shell"),
|
||||||
) {
|
) {
|
||||||
(false, Some(shell)) if shell == "default" => {
|
(false, Some(shell)) if shell == "default" => ExecutorKind::Shell(Shell::default()),
|
||||||
ExecutorKind::Shell(Shell::platform_default())
|
|
||||||
}
|
|
||||||
(false, Some(shell)) if shell == "none" => ExecutorKind::Raw,
|
(false, Some(shell)) if shell == "none" => ExecutorKind::Raw,
|
||||||
(false, Some(shell)) => ExecutorKind::Shell(Shell::parse_from_str(shell)?),
|
(false, Some(shell)) => ExecutorKind::Shell(Shell::parse_from_str(shell)?),
|
||||||
(false, None) => ExecutorKind::default(),
|
(false, None) => ExecutorKind::Shell(Shell::default()),
|
||||||
(true, Some(shell)) => ExecutorKind::Mock(Some(shell.into())),
|
(true, Some(shell)) => ExecutorKind::Mock(Some(shell.into())),
|
||||||
(true, None) => ExecutorKind::Mock(None),
|
(true, None) => ExecutorKind::Mock(None),
|
||||||
}
|
}
|
||||||
@@ -530,8 +532,8 @@ impl Options {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_platform_default_shell() {
|
fn test_default_shell() {
|
||||||
let shell = Shell::platform_default();
|
let shell = Shell::default();
|
||||||
|
|
||||||
let s = format!("{shell}");
|
let s = format!("{shell}");
|
||||||
assert_eq!(&s, DEFAULT_SHELL);
|
assert_eq!(&s, DEFAULT_SHELL);
|
||||||
|
|||||||
@@ -17,11 +17,9 @@ impl ExecutionOrderTest {
|
|||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
let tempdir = tempdir().unwrap();
|
let tempdir = tempdir().unwrap();
|
||||||
let logfile_path = tempdir.path().join("output.log");
|
let logfile_path = tempdir.path().join("output.log");
|
||||||
let mut cmd = hyperfine();
|
|
||||||
cmd.arg("-S");
|
|
||||||
|
|
||||||
ExecutionOrderTest {
|
ExecutionOrderTest {
|
||||||
cmd,
|
cmd: hyperfine(),
|
||||||
expected_content: String::new(),
|
expected_content: String::new(),
|
||||||
logfile_path,
|
logfile_path,
|
||||||
tempdir,
|
tempdir,
|
||||||
|
|||||||
@@ -259,7 +259,6 @@ fn fails_with_duplicate_parameter_names() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn fails_for_unknown_command() {
|
fn fails_for_unknown_command() {
|
||||||
hyperfine()
|
hyperfine()
|
||||||
.arg("--shell=default")
|
|
||||||
.arg("--runs=1")
|
.arg("--runs=1")
|
||||||
.arg("some-nonexisting-program-b5d9574198b7e4b12a71fa4747c0a577")
|
.arg("some-nonexisting-program-b5d9574198b7e4b12a71fa4747c0a577")
|
||||||
.assert()
|
.assert()
|
||||||
@@ -299,7 +298,6 @@ fn fails_for_failing_command_without_shell() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn fails_for_unknown_setup_command() {
|
fn fails_for_unknown_setup_command() {
|
||||||
hyperfine()
|
hyperfine()
|
||||||
.arg("--shell=default")
|
|
||||||
.arg("--runs=1")
|
.arg("--runs=1")
|
||||||
.arg("--setup=some-nonexisting-program-b5d9574198b7e4b12a71fa4747c0a577")
|
.arg("--setup=some-nonexisting-program-b5d9574198b7e4b12a71fa4747c0a577")
|
||||||
.arg("echo test")
|
.arg("echo test")
|
||||||
@@ -313,7 +311,6 @@ fn fails_for_unknown_setup_command() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn fails_for_unknown_cleanup_command() {
|
fn fails_for_unknown_cleanup_command() {
|
||||||
hyperfine()
|
hyperfine()
|
||||||
.arg("--shell=default")
|
|
||||||
.arg("--runs=1")
|
.arg("--runs=1")
|
||||||
.arg("--cleanup=some-nonexisting-program-b5d9574198b7e4b12a71fa4747c0a577")
|
.arg("--cleanup=some-nonexisting-program-b5d9574198b7e4b12a71fa4747c0a577")
|
||||||
.arg("echo test")
|
.arg("echo test")
|
||||||
@@ -327,7 +324,6 @@ fn fails_for_unknown_cleanup_command() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn fails_for_unknown_prepare_command() {
|
fn fails_for_unknown_prepare_command() {
|
||||||
hyperfine()
|
hyperfine()
|
||||||
.arg("--shell=default")
|
|
||||||
.arg("--prepare=some-nonexisting-program-b5d9574198b7e4b12a71fa4747c0a577")
|
.arg("--prepare=some-nonexisting-program-b5d9574198b7e4b12a71fa4747c0a577")
|
||||||
.arg("echo test")
|
.arg("echo test")
|
||||||
.assert()
|
.assert()
|
||||||
@@ -340,7 +336,6 @@ fn fails_for_unknown_prepare_command() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn fails_for_unknown_conclude_command() {
|
fn fails_for_unknown_conclude_command() {
|
||||||
hyperfine()
|
hyperfine()
|
||||||
.arg("--shell=default")
|
|
||||||
.arg("--conclude=some-nonexisting-program-b5d9574198b7e4b12a71fa4747c0a577")
|
.arg("--conclude=some-nonexisting-program-b5d9574198b7e4b12a71fa4747c0a577")
|
||||||
.arg("echo test")
|
.arg("echo test")
|
||||||
.assert()
|
.assert()
|
||||||
@@ -374,7 +369,6 @@ fn can_run_failing_commands_with_ignore_failure_option() {
|
|||||||
fn can_ignore_specific_exit_codes() {
|
fn can_ignore_specific_exit_codes() {
|
||||||
// Test that specifying exit code 1 ignores it
|
// Test that specifying exit code 1 ignores it
|
||||||
hyperfine()
|
hyperfine()
|
||||||
.arg("--shell=default")
|
|
||||||
.arg("--runs=1")
|
.arg("--runs=1")
|
||||||
.arg("--ignore-failure=1")
|
.arg("--ignore-failure=1")
|
||||||
.arg("exit 1")
|
.arg("exit 1")
|
||||||
@@ -383,7 +377,6 @@ fn can_ignore_specific_exit_codes() {
|
|||||||
|
|
||||||
// Test that other exit codes still fail
|
// Test that other exit codes still fail
|
||||||
hyperfine()
|
hyperfine()
|
||||||
.arg("--shell=default")
|
|
||||||
.arg("--runs=1")
|
.arg("--runs=1")
|
||||||
.arg("--ignore-failure=1")
|
.arg("--ignore-failure=1")
|
||||||
.arg("exit 2")
|
.arg("exit 2")
|
||||||
@@ -399,7 +392,6 @@ fn can_ignore_specific_exit_codes() {
|
|||||||
fn can_ignore_multiple_exit_codes() {
|
fn can_ignore_multiple_exit_codes() {
|
||||||
// Test that all specified exit codes are ignored
|
// Test that all specified exit codes are ignored
|
||||||
hyperfine()
|
hyperfine()
|
||||||
.arg("--shell=default")
|
|
||||||
.arg("--runs=1")
|
.arg("--runs=1")
|
||||||
.arg("--ignore-failure=1,2,3")
|
.arg("--ignore-failure=1,2,3")
|
||||||
.arg("exit 1")
|
.arg("exit 1")
|
||||||
@@ -407,7 +399,6 @@ fn can_ignore_multiple_exit_codes() {
|
|||||||
.success();
|
.success();
|
||||||
|
|
||||||
hyperfine()
|
hyperfine()
|
||||||
.arg("--shell=default")
|
|
||||||
.arg("--runs=1")
|
.arg("--runs=1")
|
||||||
.arg("--ignore-failure=1,2,3")
|
.arg("--ignore-failure=1,2,3")
|
||||||
.arg("exit 2")
|
.arg("exit 2")
|
||||||
@@ -415,7 +406,6 @@ fn can_ignore_multiple_exit_codes() {
|
|||||||
.success();
|
.success();
|
||||||
|
|
||||||
hyperfine()
|
hyperfine()
|
||||||
.arg("--shell=default")
|
|
||||||
.arg("--runs=1")
|
.arg("--runs=1")
|
||||||
.arg("--ignore-failure=1,2,3")
|
.arg("--ignore-failure=1,2,3")
|
||||||
.arg("exit 3")
|
.arg("exit 3")
|
||||||
@@ -424,7 +414,6 @@ fn can_ignore_multiple_exit_codes() {
|
|||||||
|
|
||||||
// Test that other exit codes still fail
|
// Test that other exit codes still fail
|
||||||
hyperfine()
|
hyperfine()
|
||||||
.arg("--shell=default")
|
|
||||||
.arg("--runs=1")
|
.arg("--runs=1")
|
||||||
.arg("--ignore-failure=1,2,3")
|
.arg("--ignore-failure=1,2,3")
|
||||||
.arg("exit 4")
|
.arg("exit 4")
|
||||||
@@ -440,7 +429,6 @@ fn can_ignore_multiple_exit_codes() {
|
|||||||
fn ignore_failure_with_all_non_zero() {
|
fn ignore_failure_with_all_non_zero() {
|
||||||
// Test explicit "all-non-zero" mode
|
// Test explicit "all-non-zero" mode
|
||||||
hyperfine()
|
hyperfine()
|
||||||
.arg("--shell=default")
|
|
||||||
.arg("--runs=1")
|
.arg("--runs=1")
|
||||||
.arg("--ignore-failure=all-non-zero")
|
.arg("--ignore-failure=all-non-zero")
|
||||||
.arg("exit 5")
|
.arg("exit 5")
|
||||||
@@ -1241,7 +1229,6 @@ fn speed_comparison_sort_order() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn windows_quote_args() {
|
fn windows_quote_args() {
|
||||||
hyperfine()
|
hyperfine()
|
||||||
.arg("--shell=default")
|
|
||||||
.arg("more \"example_input_file.txt\"")
|
.arg("more \"example_input_file.txt\"")
|
||||||
.assert()
|
.assert()
|
||||||
.success();
|
.success();
|
||||||
@@ -1251,7 +1238,6 @@ fn windows_quote_args() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn windows_quote_before_quote_args() {
|
fn windows_quote_before_quote_args() {
|
||||||
hyperfine()
|
hyperfine()
|
||||||
.arg("--shell=default")
|
|
||||||
.arg("dir \"..\\src\\\" \"..\\tests\\\"")
|
.arg("dir \"..\\src\\\" \"..\\tests\\\"")
|
||||||
.assert()
|
.assert()
|
||||||
.success();
|
.success();
|
||||||
@@ -1269,7 +1255,6 @@ fn hyperfine_iteration_env_var_in_prepare_and_conclude_commands() {
|
|||||||
let command = |phase| format!(r#"echo {phase}:{iteration} >> "iteration output.txt""#);
|
let command = |phase| format!(r#"echo {phase}:{iteration} >> "iteration output.txt""#);
|
||||||
|
|
||||||
hyperfine()
|
hyperfine()
|
||||||
.arg("--shell=default")
|
|
||||||
.current_dir(tempdir.path())
|
.current_dir(tempdir.path())
|
||||||
.arg("--runs=2")
|
.arg("--runs=2")
|
||||||
.arg("--warmup=1")
|
.arg("--warmup=1")
|
||||||
|
|||||||
Reference in new issue
Block a user