mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-12-01 12:20:59 +00:00
Compare commits
29
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39b2910415 | ||
|
|
8bd60a4e3e | ||
|
|
db45181c88 | ||
|
|
cb59053564 | ||
|
|
cf2c051812 | ||
|
|
393122dcde | ||
|
|
49fcc4be37 | ||
|
|
b04a9ec6c4 | ||
|
|
1f7284dae3 | ||
|
|
d18bdd98d7 | ||
|
|
89700a244c | ||
|
|
5f949b17ad | ||
|
|
77fcb6a6b3 | ||
|
|
80b6bdb90b | ||
|
|
0ab24d49b3 | ||
|
|
cf0ce696a7 | ||
|
|
2e4bce63d3 | ||
|
|
53bc46f6b6 | ||
|
|
a4d9c5eff7 | ||
|
|
907d38aa18 | ||
|
|
3553812436 | ||
|
|
591cce786a | ||
|
|
1d5626207a | ||
|
|
8704e76d36 | ||
|
|
e1fea57182 | ||
|
|
c05d7f9480 | ||
|
|
990ed45c3a | ||
|
|
2547342644 | ||
|
|
d7e6fa6dfb |
No files matched your search
@@ -0,0 +1,8 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: cargo
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: monthly
|
||||
time: "04:00"
|
||||
timezone: Europe/Berlin
|
||||
@@ -1,9 +1,16 @@
|
||||
# unreleased
|
||||
|
||||
- Add command exit code to output if it fails, see #342 (@KaindlJulian)
|
||||
|
||||
## Features
|
||||
|
||||
## Changes
|
||||
|
||||
- When `--export-*` commands are used, result files are created before benchmark execution
|
||||
to fail early in case of, e.g., wrong permissions. See #306 (@s1ck).
|
||||
- When `--export-*` options are used, result files are written after each individual
|
||||
benchmark command instead of writing after all benchmarks have finished. See #306 (@s1ck).
|
||||
|
||||
## Bugfixes
|
||||
|
||||
## Other
|
||||
|
||||
Generated
+47
-35
@@ -11,13 +11,19 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "approx"
|
||||
version = "0.3.2"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3"
|
||||
checksum = "3f2a05fd1bd10b2527e20a2cd32d8873d115b8b39fe219ee25f42a8aca6ba278"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arrayvec"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
@@ -71,6 +77,12 @@ version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "2.33.3"
|
||||
@@ -126,9 +138,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "csv"
|
||||
version = "1.1.3"
|
||||
version = "1.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00affe7f6ab566df61b4be3ce8cf16bc2576bca0963ceb0955e45d514bf9a279"
|
||||
checksum = "f9d58633299b24b515ac72a3f869f8b91306a3cec616a602843a383acd6f9e97"
|
||||
dependencies = [
|
||||
"bstr",
|
||||
"csv-core",
|
||||
@@ -160,11 +172,11 @@ checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.1.15"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6"
|
||||
checksum = "ee8025cf36f917e6a52cce185b7c7177689b838b7ec138364e50cc2277a56cf4"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 0.1.10",
|
||||
"libc",
|
||||
"wasi",
|
||||
]
|
||||
@@ -184,13 +196,13 @@ version = "1.11.0"
|
||||
dependencies = [
|
||||
"approx",
|
||||
"atty",
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"clap",
|
||||
"colored",
|
||||
"csv",
|
||||
"indicatif",
|
||||
"libc",
|
||||
"rand 0.7.3",
|
||||
"rand 0.8.3",
|
||||
"rust_decimal",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -225,9 +237,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.79"
|
||||
version = "0.2.86"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743"
|
||||
checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
@@ -363,15 +375,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.7.3"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
|
||||
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"libc",
|
||||
"rand_chacha 0.2.2",
|
||||
"rand_core 0.5.1",
|
||||
"rand_hc 0.2.0",
|
||||
"rand_chacha 0.3.0",
|
||||
"rand_core 0.6.0",
|
||||
"rand_hc 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -386,12 +397,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.2.2"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
|
||||
checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core 0.5.1",
|
||||
"rand_core 0.6.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -411,9 +422,9 @@ checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.5.1"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
|
||||
checksum = "a8b34ba8cfb21243bd8df91854c830ff0d785fff2e82ebd4434c2644cb9ada18"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
@@ -429,11 +440,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
|
||||
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
|
||||
dependencies = [
|
||||
"rand_core 0.5.1",
|
||||
"rand_core 0.6.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -524,10 +535,11 @@ checksum = "8cab7a364d15cde1e505267766a2d3c4e22a843e1a601f0fa7564c0f82ced11c"
|
||||
|
||||
[[package]]
|
||||
name = "rust_decimal"
|
||||
version = "1.8.1"
|
||||
version = "1.10.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c9e81662973c7a8d9663e64a0de4cd642b89a21d64966e3d99606efdc5fb0cc6"
|
||||
checksum = "dc7f5b8840fb1f83869a3e1dfd06d93db79ea05311ac5b42b8337d3371caa4f1"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"num-traits",
|
||||
"serde",
|
||||
]
|
||||
@@ -540,18 +552,18 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.117"
|
||||
version = "1.0.123"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a"
|
||||
checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.117"
|
||||
version = "1.0.123"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e"
|
||||
checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -560,9 +572,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.59"
|
||||
version = "1.0.64"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dcac07dbffa1c65e7f816ab9eba78eb142c6d44410f4eeba1e26e4f5dfa56b95"
|
||||
checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
@@ -587,9 +599,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.44"
|
||||
version = "1.0.60"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e03e57e4fcbfe7749842d53e24ccb9aa12b7252dbe5e91d2acad31834c8b8fdd"
|
||||
checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
||||
+5
-5
@@ -16,12 +16,12 @@ colored = "2.0"
|
||||
indicatif = "0.15"
|
||||
statistical = "1.0"
|
||||
atty = "0.2"
|
||||
cfg-if = "0.1"
|
||||
csv = "1.1.3"
|
||||
cfg-if = "1.0"
|
||||
csv = "1.1.5"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
rust_decimal = "1.8"
|
||||
rand = "0.7"
|
||||
rust_decimal = "1.10"
|
||||
rand = "0.8"
|
||||
|
||||
[target.'cfg(not(windows))'.dependencies]
|
||||
libc = "0.2"
|
||||
@@ -35,7 +35,7 @@ default-features = false
|
||||
features = ["suggestions", "color", "wrap_help"]
|
||||
|
||||
[dev-dependencies]
|
||||
approx = "0.3"
|
||||
approx = "0.4"
|
||||
|
||||
[build-dependencies]
|
||||
clap = "2"
|
||||
|
||||
@@ -77,6 +77,26 @@ hyperfine --parameter-scan delay 0.3 0.7 -D 0.2 'sleep {delay}'
|
||||
```
|
||||
This runs `sleep 0.3`, `sleep 0.5` and `sleep 0.7`.
|
||||
|
||||
### Shell functions and aliases
|
||||
|
||||
If you are using bash, you can export shell functions to directly benchmark them with hyperfine:
|
||||
|
||||
```
|
||||
$ my_function() { sleep 1; }
|
||||
$ export -f my_function
|
||||
$ hyperfine my_function
|
||||
```
|
||||
|
||||
If you are using a different shell, or if you want to benchmark shell aliases, you may try to put
|
||||
them in a separate file:
|
||||
|
||||
```bash
|
||||
echo 'my_function() { sleep 1 }' > /tmp/my_function.sh
|
||||
echo 'alias my_alias="sleep 1"' > /tmp/my_alias.sh
|
||||
hyperfine 'source /tmp/my_function.sh; eval my_function'
|
||||
hyperfine 'source /tmp/my_alias.sh; eval my_alias'
|
||||
```
|
||||
|
||||
### Export results
|
||||
|
||||
Hyperfine has multiple options for exporting benchmark results: CSV, JSON, Markdown (see `--help`
|
||||
|
||||
@@ -10,16 +10,26 @@ import matplotlib.pyplot as plt
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("file", help="JSON file with benchmark results")
|
||||
parser.add_argument("--title", help="Plot title")
|
||||
parser.add_argument(
|
||||
"--labels", help="Comma-separated list of entries for the plot legend"
|
||||
)
|
||||
parser.add_argument("--bins", help="Number of bins (default: auto)")
|
||||
parser.add_argument(
|
||||
"--type", help="Type of histogram (*bar*, barstacked, step, stepfilled)"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-o", "--output", help="Save image to the given filename."
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
with open(args.file) as f:
|
||||
results = json.load(f)["results"]
|
||||
|
||||
commands = [b["command"] for b in results]
|
||||
if args.labels:
|
||||
labels = args.labels.split(",")
|
||||
else:
|
||||
labels = [b["command"] for b in results]
|
||||
all_times = [b["times"] for b in results]
|
||||
|
||||
t_min = np.min(list(map(np.min, all_times)))
|
||||
@@ -29,7 +39,7 @@ bins = int(args.bins) if args.bins else "auto"
|
||||
histtype = args.type if args.type else "bar"
|
||||
|
||||
plt.hist(
|
||||
all_times, label=commands, bins=bins, histtype=histtype, range=(t_min, t_max),
|
||||
all_times, label=labels, bins=bins, histtype=histtype, range=(t_min, t_max),
|
||||
)
|
||||
plt.legend(prop={"family": ["Source Code Pro", "Fira Mono", "Courier New"]})
|
||||
|
||||
@@ -37,4 +47,7 @@ plt.xlabel("Time [s]")
|
||||
if args.title:
|
||||
plt.title(args.title)
|
||||
|
||||
plt.show()
|
||||
if args.output:
|
||||
plt.savefig(args.output)
|
||||
else:
|
||||
plt.show()
|
||||
@@ -25,6 +25,9 @@ parser.add_argument(
|
||||
parser.add_argument(
|
||||
"--titles", help="Comma-separated list of titles for the plot legend"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-o", "--output", help="Save image to the given filename."
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
if args.parameter_name is not None:
|
||||
@@ -100,4 +103,7 @@ if args.log_x:
|
||||
if args.titles:
|
||||
plt.legend(args.titles.split(","))
|
||||
|
||||
plt.show()
|
||||
if args.output:
|
||||
plt.savefig(args.output)
|
||||
else:
|
||||
plt.show()
|
||||
+10
-2
@@ -18,6 +18,10 @@ parser.add_argument("--title", help="Plot Title")
|
||||
parser.add_argument(
|
||||
"--labels", help="Comma-separated list of entries for the plot legend"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-o", "--output", help="Save image to the given filename."
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
with open(args.file) as f:
|
||||
@@ -36,8 +40,12 @@ colors = [cmap(val / len(times)) for val in range(len(times))]
|
||||
for patch, color in zip(boxplot["boxes"], colors):
|
||||
patch.set_facecolor(color)
|
||||
|
||||
plt.title(args.title)
|
||||
if args.title:
|
||||
plt.title(args.title)
|
||||
plt.legend(handles=boxplot["boxes"], labels=labels, loc="best", fontsize="medium")
|
||||
plt.ylabel("Time [s]")
|
||||
plt.ylim(0, None)
|
||||
plt.show()
|
||||
if args.output:
|
||||
plt.savefig(args.output)
|
||||
else:
|
||||
plt.show()
|
||||
@@ -63,9 +63,15 @@ pub fn time_shell_command(
|
||||
if failure_action == CmdFailureAction::RaiseError && !result.status.success() {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"Command terminated with non-zero exit code. \
|
||||
Use the '-i'/'--ignore-failure' option if you want to ignore this. \
|
||||
Alternatively, use the '--show-output' option to debug what went wrong.",
|
||||
format!(
|
||||
"{}. \
|
||||
Use the '-i'/'--ignore-failure' option if you want to ignore this. \
|
||||
Alternatively, use the '--show-output' option to debug what went wrong.",
|
||||
result.status.code().map_or(
|
||||
"The process has been terminated by a signal".into(),
|
||||
|c| format!("Command terminated with non-zero exit code: {}", c)
|
||||
)
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ use self::csv::CsvExporter;
|
||||
use self::json::JsonExporter;
|
||||
use self::markdown::MarkdownExporter;
|
||||
|
||||
use std::fs::File;
|
||||
use std::fs::{File, OpenOptions};
|
||||
use std::io::{Result, Write};
|
||||
|
||||
use crate::hyperfine::types::BenchmarkResult;
|
||||
@@ -55,7 +55,9 @@ impl ExportManager {
|
||||
}
|
||||
|
||||
/// Add an additional exporter to the ExportManager
|
||||
pub fn add_exporter(&mut self, export_type: ExportType, filename: &str) {
|
||||
pub fn add_exporter(&mut self, export_type: ExportType, filename: &str) -> Result<()> {
|
||||
let _ = File::create(filename)?;
|
||||
|
||||
let exporter: Box<dyn Exporter> = match export_type {
|
||||
ExportType::Asciidoc => Box::new(AsciidocExporter::default()),
|
||||
ExportType::Csv => Box::new(CsvExporter::default()),
|
||||
@@ -66,10 +68,12 @@ impl ExportManager {
|
||||
exporter,
|
||||
filename: filename.to_string(),
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Write the given results to all Exporters contained within this manager
|
||||
pub fn write_results(&self, results: Vec<BenchmarkResult>, unit: Option<Unit>) -> Result<()> {
|
||||
pub fn write_results(&self, results: &[BenchmarkResult], unit: Option<Unit>) -> Result<()> {
|
||||
for e in &self.exporters {
|
||||
let file_content = e.exporter.serialize(&results, unit)?;
|
||||
write_to_file(&e.filename, &file_content)?;
|
||||
@@ -80,6 +84,6 @@ impl ExportManager {
|
||||
|
||||
/// Write the given content to a file with the specified name
|
||||
fn write_to_file(filename: &str, content: &[u8]) -> Result<()> {
|
||||
let mut file = File::create(filename)?;
|
||||
let mut file = OpenOptions::new().write(true).open(filename)?;
|
||||
file.write_all(content)
|
||||
}
|
||||
@@ -13,7 +13,7 @@ pub const OUTLIER_THRESHOLD: f64 = 1.4826 * 10.0;
|
||||
|
||||
/// Compute modifized Z-scores for a given sample. A (unmodified) Z-score is defined by
|
||||
/// `(x_i - x_mean)/x_stddev` whereas the modified Z-score is defined by `(x_i - x_median)/MAD`
|
||||
/// where MAD is the median average deviation.
|
||||
/// where MAD is the median absolute deviation.
|
||||
///
|
||||
/// References:
|
||||
/// - <https://en.wikipedia.org/wiki/Median_absolute_deviation>
|
||||
|
||||
+22
-18
@@ -49,6 +49,15 @@ fn run(
|
||||
// Run the benchmarks
|
||||
for (num, cmd) in commands.iter().enumerate() {
|
||||
timing_results.push(run_benchmark(num, cmd, shell_spawning_time, options)?);
|
||||
|
||||
// Export (intermediate) results
|
||||
let ans = export_manager.write_results(&timing_results, options.time_unit);
|
||||
if let Err(e) = ans {
|
||||
error(&format!(
|
||||
"The following error occurred while exporting: {}",
|
||||
e
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// Print relative speed comparison
|
||||
@@ -56,23 +65,17 @@ fn run(
|
||||
write_benchmark_comparison(&timing_results);
|
||||
}
|
||||
|
||||
// Export results
|
||||
let ans = export_manager.write_results(timing_results, options.time_unit);
|
||||
if let Err(e) = ans {
|
||||
error(&format!(
|
||||
"The following error occurred while exporting: {}",
|
||||
e
|
||||
));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let matches = get_arg_matches(env::args_os());
|
||||
let options = build_hyperfine_options(&matches);
|
||||
let export_manager = build_export_manager(&matches);
|
||||
let commands = build_commands(&matches);
|
||||
let export_manager = match build_export_manager(&matches) {
|
||||
Ok(export_manager) => export_manager,
|
||||
Err(ref e) => error(&e.to_string())
|
||||
};
|
||||
|
||||
let res = match options {
|
||||
Ok(ref opts) => run(&commands, &opts, &export_manager),
|
||||
@@ -202,20 +205,21 @@ fn build_hyperfine_options<'a>(
|
||||
|
||||
/// Build the ExportManager that will export the results specified
|
||||
/// in the given ArgMatches
|
||||
fn build_export_manager(matches: &ArgMatches<'_>) -> ExportManager {
|
||||
fn build_export_manager(matches: &ArgMatches<'_>) -> io::Result<ExportManager> {
|
||||
let mut export_manager = ExportManager::new();
|
||||
{
|
||||
let mut add_exporter = |flag, exporttype| {
|
||||
let mut add_exporter = |flag, exporttype| -> io::Result<()> {
|
||||
if let Some(filename) = matches.value_of(flag) {
|
||||
export_manager.add_exporter(exporttype, filename);
|
||||
export_manager.add_exporter(exporttype, filename)?;
|
||||
}
|
||||
Ok(())
|
||||
};
|
||||
add_exporter("export-asciidoc", ExportType::Asciidoc);
|
||||
add_exporter("export-json", ExportType::Json);
|
||||
add_exporter("export-csv", ExportType::Csv);
|
||||
add_exporter("export-markdown", ExportType::Markdown);
|
||||
add_exporter("export-asciidoc", ExportType::Asciidoc)?;
|
||||
add_exporter("export-json", ExportType::Json)?;
|
||||
add_exporter("export-csv", ExportType::Csv)?;
|
||||
add_exporter("export-markdown", ExportType::Markdown)?;
|
||||
}
|
||||
export_manager
|
||||
Ok(export_manager)
|
||||
}
|
||||
|
||||
/// Build the commands to benchmark
|
||||
|
||||
Reference in new issue
Block a user