mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-16 01:11:30 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
871c82a297 |
No files matched your search
+22
-23
@@ -1,49 +1,48 @@
|
||||
# v2.0.0
|
||||
# v2.0.0-alpha.2
|
||||
|
||||
See the breaking changes below when migrating from hyperfine 1.x.
|
||||
## Changes
|
||||
|
||||
- Always run `--setup`, `--prepare`, `--conclude`, and `--cleanup` commands in a shell, even when benchmarked commands run directly. Improve error messages for these commands, see #990 (@sharkdp).
|
||||
- Require an explicit shell choice for commands containing unquoted, standalone shell operators such as `&&` or `>`: use `-S` to interpret shell syntax or `-N` to pass operators as literal arguments (@sharkdp).
|
||||
- Use a compact output layout on narrow terminals (@sharkdp).
|
||||
- Make plotting and analysis scripts runnable directly from GitHub with `uvx --from 'git+https://github.com/sharkdp/hyperfine' <script>` (@sharkdp).
|
||||
|
||||
# v2.0.0-alpha.1
|
||||
|
||||
This is the first alpha release of hyperfine 2.0. Command-line options and export formats may change before the stable release. See the breaking changes below when migrating from hyperfine 1.x.
|
||||
|
||||
## Features
|
||||
|
||||
- Add support for alternative performance metrics (peak memory usage, instructions, CPU cycles, cache misses, branch misses, ...). By default, hyperfine will now display wall-clock time and peak memory usage, but users can use the [new `--metrics` option](README.md#choosing-metrics-and-units) to select different performance metrics. The terminal output now shows an overview of all selected performance metrics, including relative changes.
|
||||
- Add `--env` to set environment variables even without an intermediate shell (which is the new default behavior, see below). For example:
|
||||
|
||||
```sh
|
||||
# Parameterized benchmark, comparing different thread counts:
|
||||
hyperfine -P threads 1 8 --env 'OMP_NUM_THREADS={threads}' 'my_command'
|
||||
```
|
||||
|
||||
- The plotting and analysis scripts now support different metrics as well, see #981 and #984 (@sharkdp).
|
||||
- Add support for alternative performance metrics (peak memory usage, CPU cycles, instructions, cache misses, branch misses, ...). By default, hyperfine will now display wall-clock time and peak memory usage (wall-clock time only on Windows),
|
||||
but users can use the new `--metrics` option to select different performance metrics.
|
||||
- The terminal output now shows an overview of all selected performance metrics, including relative changes.
|
||||
- Python plotting and analysis scripts support the new JSON format and can select performance metrics with `--metric`, see #981 and #984 (@sharkdp).
|
||||
|
||||
## Breaking changes
|
||||
|
||||
- Benchmarked commands are now executed directly by default, without an intermediate shell (`--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>`. See [the rationale for this change](https://github.com/sharkdp/hyperfine/issues/787#issuecomment-6038898252).
|
||||
- Always run `--setup`, `--prepare`, `--conclude`, and `--cleanup` commands in a shell, even when using `--shell=none` (the new default behavior), see #990 (@sharkdp).
|
||||
- The JSON format for `--export-json` has changed (schema version 2). The [new format](README.md#json) now includes metadata, per-run measurements, and statistical summaries for all measured quantities, see #790 (@sharkdp). Code that reads those exported JSON files must be updated. For example, `results[i].mean` is now `results[i].summary.time_wall_clock.mean`, and `results[i].times` is replaced by `results[i].measurements[j].time_wall_clock.value`. The new structure looks like this:
|
||||
- Benchmarked commands are now executed directly by default, without an intermediate shell (`--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>`.
|
||||
- The JSON format for `--export-json` has changed (schema version 2). The new format now includes metadata, per-run measurements, and statistical summaries for all measured quantities, see #790 (@sharkdp). Code that reads those exported JSON files must be updated. For example, `results[i].mean` is now `results[i].summary.time_wall_clock.mean`, and `results[i].times` is replaced by `results[i].measurements[j].time_wall_clock.value`. The new structure looks like this:
|
||||
|
||||
```python
|
||||
{
|
||||
"schema_version": 2,
|
||||
"primary_metric": "time_wall_clock",
|
||||
"metadata": {
|
||||
"hyperfine_version": "2.0.0",
|
||||
"hyperfine_version": "2.0.0-alpha.1",
|
||||
"start_time": "2026-10-06T12:00:00Z",
|
||||
"platform": {"os": "Linux", "architecture": "x86_64"}
|
||||
},
|
||||
"results": [
|
||||
{
|
||||
"command": "sleep 1", # Actual command after parameter substitution
|
||||
"name": "wait 1s", # Optional custom or automatically generated name
|
||||
"name": "wait 1s", # Optional custom name, separate from the command
|
||||
"parameters": {"duration": {"value": "1"}}, # Values are now objects
|
||||
"environment": {"OMP_NUM_THREADS": "8"}, # Only present with --env overrides
|
||||
"measurements": [ # One entry per run, excluding warmups
|
||||
{
|
||||
"time_wall_clock": {"value": 1.0, "unit": "second"},
|
||||
"time_cpu": {"value": 0.0, "unit": "second"},
|
||||
"time_user": {"value": 0.0, "unit": "second"},
|
||||
"time_system": {"value": 0.0, "unit": "second"},
|
||||
"memory_peak_resident": {"value": 1048576.0, "unit": "byte"},
|
||||
"cpu_cycles": {"value": 5000000}, # Hardware counters, when available
|
||||
"instructions": {"value": 10000000},
|
||||
"exit_code": 0
|
||||
},
|
||||
... # Further runs omitted
|
||||
@@ -65,11 +64,11 @@ See the breaking changes below when migrating from hyperfine 1.x.
|
||||
}
|
||||
```
|
||||
|
||||
Times are always exported in seconds and memory in bytes. Hardware counters and their summaries have no `unit` field. Unavailable memory measurements and hardware counters are omitted; other available counters may also be included. `stddev` is `null` for a single run.
|
||||
Times are always exported in seconds and memory in bytes.
|
||||
- `--time-unit`/`-u` has been removed. Units can now be selected using the `--metrics METRIC[:UNIT],…` option, e.g. `--metrics time_wall_clock:ms,memory_peak_resident:MiB`.
|
||||
- `--sort` has been removed. It complicated hyperfine significantly and doesn't make too much sense with the new output format.
|
||||
- `--reference` and `--reference-name` have been removed (for now). The first command is always considered as the reference command. Invocations using `--reference` now show migration guidance to put the reference command first.
|
||||
- The format of [Markdown](README.md#markdown), AsciiDoc and org-mode, and [CSV](README.md#csv) exports has also been changed. Markdown, AsciiDoc, and org-mode contain only the primary metric (the first metric selected by `--metrics`). CSV exports all selected metrics side by side.
|
||||
- `--reference` and `--reference-name` have been removed (for now). The first command is always considered as the reference command.
|
||||
- The format of Markdown, AsciiDoc, org-mode and CSV exports has also been changed. These formats contain only the primary metric (the first metric selected by `--metrics`). CSV now includes columns with the name and the unit of the primary metric.
|
||||
|
||||
# v1.21.0
|
||||
|
||||
|
||||
+1
-1
@@ -13,5 +13,5 @@ authors:
|
||||
repository-code: 'https://github.com/sharkdp/hyperfine'
|
||||
abstract: A command-line benchmarking tool.
|
||||
license: MIT
|
||||
version: 2.0.0
|
||||
version: 2.0.0-alpha.2
|
||||
date-released: '2026-10-07'
|
||||
Generated
+1
-1
@@ -377,7 +377,7 @@ checksum = "15cdd26707701c53297e2fa6afb323d55fbc1d0810c3aec078ae3ef0424c3c15"
|
||||
|
||||
[[package]]
|
||||
name = "hyperfine"
|
||||
version = "2.0.0"
|
||||
version = "2.0.0-alpha.2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"approx",
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
|
||||
name = "hyperfine"
|
||||
readme = "README.md"
|
||||
repository = "https://github.com/sharkdp/hyperfine"
|
||||
version = "2.0.0"
|
||||
version = "2.0.0-alpha.2"
|
||||
edition = "2018"
|
||||
build = "build.rs"
|
||||
rust-version = "1.97.0"
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
A command-line benchmarking tool.
|
||||
|
||||
<img width="800" height="195" alt="hyperfine-demo-800" src="https://github.com/user-attachments/assets/9a5a45d3-df3f-4e0e-8cc9-5d8153f39e48" />
|
||||
|
||||
<img width="839" height="205" alt="hyperfine demo" src="https://github.com/user-attachments/assets/13c20b1d-39c1-4da1-8fcb-0c775dd032f5" />
|
||||
|
||||
*(hyperfine in action, benchmarking [`mypy`](https://mypy-lang.org/) and [`ty`](https://ty.dev/))*
|
||||
|
||||
@@ -265,9 +264,8 @@ You can also use a preset to select a group of metrics:
|
||||
|
||||
### Exporting results
|
||||
|
||||
Hyperfine can export results to CSV, JSON, Markdown, AsciiDoc, and org-mode. CSV exports all
|
||||
selected metrics, while Markdown, AsciiDoc, and org-mode contain only the primary metric,
|
||||
which is the first metric selected by `--metrics`.
|
||||
Hyperfine can export results to CSV, JSON, Markdown, AsciiDoc, and org-mode. Non-JSON formats
|
||||
contain only the primary metric, which is the first metric selected by `--metrics`.
|
||||
|
||||
#### Markdown
|
||||
|
||||
@@ -303,14 +301,6 @@ uvx --from 'git+https://github.com/sharkdp/hyperfine' \
|
||||
|---:|---:|
|
||||
|
||||
|
||||
#### CSV
|
||||
|
||||
Use `--export-csv <file>` to export one row per command. Each metric selected by `--metrics`
|
||||
contributes a group of columns, in selection order: `<metric>_unit`, `<metric>_mean`,
|
||||
`<metric>_stddev`, `<metric>_median`, `<metric>_min`, and `<metric>_max`.
|
||||
|
||||
CSV uses explicitly selected units, or base units (seconds, bytes, or counts) when omitted.
|
||||
|
||||
### Detailed benchmark flowchart
|
||||
|
||||
The following chart explains the execution order of various benchmark runs when using options
|
||||
@@ -331,8 +321,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`:
|
||||
```
|
||||
wget https://github.com/sharkdp/hyperfine/releases/download/v2.0.0/hyperfine_2.0.0_amd64.deb
|
||||
sudo dpkg -i hyperfine_2.0.0_amd64.deb
|
||||
wget https://github.com/sharkdp/hyperfine/releases/download/v1.21.0/hyperfine_1.21.0_amd64.deb
|
||||
sudo dpkg -i hyperfine_1.21.0_amd64.deb
|
||||
```
|
||||
|
||||
### On Fedora
|
||||
|
||||
+4
-6
@@ -243,7 +243,7 @@ of the tool.
|
||||
.HP
|
||||
\fB\-\-metrics\fR \fIMETRIC[:UNIT],...|default|time|all\fP
|
||||
.IP
|
||||
Select the metrics to measure, in order, with an optional unit for each.
|
||||
Select the metrics to display, in order, with an optional unit for each.
|
||||
Default: \fBtime_wall_clock,memory_peak_resident\fR, or \fBtime_wall_clock\fR
|
||||
on Windows, where peak resident memory is not yet supported.
|
||||
.IP
|
||||
@@ -277,11 +277,9 @@ Export the primary metric's summary statistics as an AsciiDoc table to the given
|
||||
.HP
|
||||
\fB\-\-export\-csv\fR \fIFILE\fP
|
||||
.IP
|
||||
Export summary statistics for all selected metrics as CSV to the given \fIFILE\fP,
|
||||
one row per command. Each metric contributes columns for unit, mean, stddev, median,
|
||||
min, and max, prefixed with the metric name, in selection order. The command column
|
||||
comes first and parameter columns come last. Use the explicitly selected units,
|
||||
or base units (seconds, bytes, or unscaled counts) when omitted.
|
||||
Export the primary metric's summary statistics as CSV to the given \fIFILE\fP,
|
||||
identifying the metric and unit explicitly. Use the explicitly selected unit,
|
||||
or the base unit (seconds, bytes, or unscaled counts) when omitted.
|
||||
.HP
|
||||
\fB\-\-export\-json\fR \fIFILE\fP
|
||||
.IP
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "hyperfine-scripts"
|
||||
version = "2.0.0"
|
||||
version = "0.1.0"
|
||||
description = "Plot and analyze hyperfine JSON benchmark results"
|
||||
requires-python = ">=3.10"
|
||||
license-files = ["LICENSE-APACHE", "LICENSE-MIT"]
|
||||
|
||||
@@ -69,7 +69,7 @@ fn generate_results(args: &[&'static str]) -> Result<Vec<BenchmarkResult>> {
|
||||
assert_eq!(options.executor_kind, ExecutorKind::Mock(None));
|
||||
|
||||
let commands = Commands::from_cli_arguments(&cli_arguments)?;
|
||||
let export_manager = ExportManager::from_cli_arguments(&cli_arguments, &options.metrics)?;
|
||||
let export_manager = ExportManager::from_cli_arguments(&cli_arguments, options.metrics[0])?;
|
||||
|
||||
options.validate_against_command_list(&commands)?;
|
||||
|
||||
|
||||
+3
-17
@@ -50,19 +50,6 @@ fn build_command() -> Command {
|
||||
.value_hint(ValueHint::CommandString)
|
||||
.value_parser(NonEmptyStringValueParser::new()),
|
||||
)
|
||||
// Retain the removed option to provide migration guidance for old invocations.
|
||||
.arg(
|
||||
Arg::new("reference")
|
||||
.long("reference")
|
||||
.hide(true)
|
||||
.value_name("CMD")
|
||||
.num_args(0..=1)
|
||||
.default_missing_value("")
|
||||
.value_parser(|_: &str| -> Result<String, String> {
|
||||
Err("The --reference option has been removed. Put your reference command first instead.".into())
|
||||
})
|
||||
.help("Removed: put your reference command first instead."),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("metrics")
|
||||
.long("metrics")
|
||||
@@ -71,7 +58,7 @@ fn build_command() -> Command {
|
||||
.hide_default_value(true)
|
||||
.help("Performance metrics to measure, in order.\n\n\
|
||||
This is either a preset name, or a comma-separated list of metrics with optional units. \
|
||||
CSV exports all selected metrics; markup exports use the first metric. \
|
||||
The first metric is used for non-JSON exports, \
|
||||
JSON always includes all collected metrics.\n\n\
|
||||
Presets (use one on its own):\n \
|
||||
default Wall-clock time and peak RSS\n \
|
||||
@@ -338,10 +325,9 @@ fn build_command() -> Command {
|
||||
.action(ArgAction::Set)
|
||||
.value_name("FILE")
|
||||
.value_hint(ValueHint::FilePath)
|
||||
.help("Export summary statistics for all selected metrics as CSV to the given FILE. If you need \
|
||||
.help("Export the primary metric summary statistics as CSV to the given FILE. If you need \
|
||||
all metrics for each individual run, use the JSON export format. \
|
||||
Column names are prefixed with the metric name. \
|
||||
Use the explicitly selected units, or base units when unspecified."),
|
||||
Use the explicitly selected unit, or the base unit when unspecified."),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("export-json")
|
||||
|
||||
+49
-54
@@ -4,34 +4,23 @@ use super::Exporter;
|
||||
use crate::benchmark::benchmark_result::BenchmarkResult;
|
||||
use crate::metric::MetricSelection;
|
||||
|
||||
use anyhow::Result;
|
||||
use anyhow::{Context, Result};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct CsvExporter {}
|
||||
|
||||
impl Exporter for CsvExporter {
|
||||
fn serialize(
|
||||
&self,
|
||||
results: &[BenchmarkResult],
|
||||
metrics: &[MetricSelection],
|
||||
) -> Result<Vec<u8>> {
|
||||
// Omit metrics unavailable for all commands (possible with `--metrics all`).
|
||||
let metrics: Vec<_> = metrics
|
||||
.iter()
|
||||
.filter(|selection| {
|
||||
results
|
||||
.iter()
|
||||
.any(|result| selection.metric.summarize(&result.measurements).is_some())
|
||||
})
|
||||
.collect();
|
||||
fn serialize(&self, results: &[BenchmarkResult], primary: MetricSelection) -> Result<Vec<u8>> {
|
||||
// CSV never chooses units automatically: an omitted suffix means base units.
|
||||
let unit = primary.csv_unit();
|
||||
let mut writer = WriterBuilder::new().from_writer(vec![]);
|
||||
let mut headers = vec!["command".to_owned()];
|
||||
for selection in &metrics {
|
||||
headers.extend(
|
||||
["unit", "mean", "stddev", "median", "min", "max"]
|
||||
.map(|field| format!("{}_{field}", selection.metric.name())),
|
||||
);
|
||||
}
|
||||
let mut headers: Vec<String> = [
|
||||
"command", "metric", "unit", "mean", "stddev", "median", "min", "max",
|
||||
]
|
||||
.iter()
|
||||
.copied()
|
||||
.map(str::to_owned)
|
||||
.collect();
|
||||
if let Some(result) = results.first() {
|
||||
headers.extend(
|
||||
result
|
||||
@@ -43,28 +32,36 @@ impl Exporter for CsvExporter {
|
||||
writer.write_record(headers)?;
|
||||
|
||||
for result in results {
|
||||
let mut fields = vec![result.get_name().to_owned()];
|
||||
for selection in &metrics {
|
||||
// CSV never chooses units automatically: an omitted suffix means base units.
|
||||
let unit = selection.csv_unit();
|
||||
let stats = selection.metric.summarize(&result.measurements);
|
||||
fields.push(unit.symbol.to_owned());
|
||||
// Preserve numeric precision rather than using rounded display values.
|
||||
fields.extend(
|
||||
[
|
||||
stats.map(|stats| stats.mean),
|
||||
stats.and_then(|stats| stats.stddev),
|
||||
stats.map(|stats| stats.median),
|
||||
stats.map(|stats| stats.min),
|
||||
stats.map(|stats| stats.max),
|
||||
]
|
||||
.map(|value| {
|
||||
value
|
||||
.map(|value| (value / unit.scale).to_string())
|
||||
.unwrap_or_default()
|
||||
}),
|
||||
);
|
||||
}
|
||||
let stats = primary
|
||||
.metric
|
||||
.summarize(&result.measurements)
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"Metric '{}' is unavailable for '{}'",
|
||||
primary.metric.name(),
|
||||
result.get_name()
|
||||
)
|
||||
})?;
|
||||
let mut fields = vec![
|
||||
result.get_name().to_owned(),
|
||||
primary.metric.name().to_owned(),
|
||||
unit.symbol.to_owned(),
|
||||
];
|
||||
// Preserve numeric precision rather than using rounded display values.
|
||||
fields.extend(
|
||||
[
|
||||
Some(stats.mean),
|
||||
stats.stddev,
|
||||
Some(stats.median),
|
||||
Some(stats.min),
|
||||
Some(stats.max),
|
||||
]
|
||||
.map(|value| {
|
||||
value
|
||||
.map(|value| (value / unit.scale).to_string())
|
||||
.unwrap_or_default()
|
||||
}),
|
||||
);
|
||||
fields.extend(
|
||||
result
|
||||
.parameters
|
||||
@@ -196,18 +193,15 @@ fn test_csv() {
|
||||
|
||||
let actual = String::from_utf8(
|
||||
exporter
|
||||
.serialize(
|
||||
&results,
|
||||
&MetricSelection::parse_list("time_wall_clock,memory_peak_resident").unwrap(),
|
||||
)
|
||||
.serialize(&results, MetricSelection::default())
|
||||
.unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
insta::assert_snapshot!(actual, @r#"
|
||||
command,time_wall_clock_unit,time_wall_clock_mean,time_wall_clock_stddev,time_wall_clock_median,time_wall_clock_min,time_wall_clock_max,memory_peak_resident_unit,memory_peak_resident_mean,memory_peak_resident_stddev,memory_peak_resident_median,memory_peak_resident_min,memory_peak_resident_max,parameter_bar,parameter_foo
|
||||
command_a,s,9,2.6457513110645907,8,7,12,B,1024,0,1024,1024,1024,two,one
|
||||
command_b,s,18,1,18,17,19,B,1024,0,1024,1024,1024,seven,one
|
||||
command,metric,unit,mean,stddev,median,min,max,parameter_bar,parameter_foo
|
||||
command_a,time_wall_clock,s,9,2.6457513110645907,8,7,12,two,one
|
||||
command_b,time_wall_clock,s,18,1,18,17,19,seven,one
|
||||
"#);
|
||||
|
||||
for (selection, unit, mean) in [
|
||||
@@ -215,11 +209,12 @@ fn test_csv() {
|
||||
("memory_peak_resident:KiB", "KiB", "1"),
|
||||
] {
|
||||
let output = exporter
|
||||
.serialize(&results, &MetricSelection::parse_list(selection).unwrap())
|
||||
.serialize(&results, MetricSelection::parse_list(selection).unwrap()[0])
|
||||
.unwrap();
|
||||
let mut reader = csv::Reader::from_reader(output.as_slice());
|
||||
let row = reader.records().next().unwrap().unwrap();
|
||||
assert_eq!(&row[1], unit);
|
||||
assert_eq!(&row[2], mean);
|
||||
assert_eq!(&row[1], "memory_peak_resident");
|
||||
assert_eq!(&row[2], unit);
|
||||
assert_eq!(&row[3], mean);
|
||||
}
|
||||
}
|
||||
+1
-6
@@ -65,12 +65,7 @@ pub struct JsonExporter {
|
||||
}
|
||||
|
||||
impl Exporter for JsonExporter {
|
||||
fn serialize(
|
||||
&self,
|
||||
results: &[BenchmarkResult],
|
||||
metrics: &[MetricSelection],
|
||||
) -> Result<Vec<u8>> {
|
||||
let primary = metrics[0];
|
||||
fn serialize(&self, results: &[BenchmarkResult], primary: MetricSelection) -> Result<Vec<u8>> {
|
||||
let mut output = to_vec_pretty(&HyperfineSummary {
|
||||
schema_version: JSON_SCHEMA_VERSION,
|
||||
metadata: &self.metadata,
|
||||
|
||||
@@ -77,12 +77,7 @@ pub trait MarkupExporter {
|
||||
}
|
||||
|
||||
impl<T: MarkupExporter> Exporter for T {
|
||||
fn serialize(
|
||||
&self,
|
||||
results: &[BenchmarkResult],
|
||||
metrics: &[MetricSelection],
|
||||
) -> Result<Vec<u8>> {
|
||||
let primary = metrics[0];
|
||||
fn serialize(&self, results: &[BenchmarkResult], primary: MetricSelection) -> Result<Vec<u8>> {
|
||||
let stats: Vec<_> = results
|
||||
.iter()
|
||||
.map(|result| {
|
||||
|
||||
+6
-10
@@ -44,12 +44,8 @@ pub enum ExportType {
|
||||
|
||||
/// Interface for different exporters.
|
||||
trait Exporter {
|
||||
/// Export the given entries using a nonempty list of selected metrics, primary first.
|
||||
fn serialize(
|
||||
&self,
|
||||
results: &[BenchmarkResult],
|
||||
metrics: &[MetricSelection],
|
||||
) -> Result<Vec<u8>>;
|
||||
/// Export the given entries in the serialized form.
|
||||
fn serialize(&self, results: &[BenchmarkResult], primary: MetricSelection) -> Result<Vec<u8>>;
|
||||
}
|
||||
|
||||
pub enum ExportTarget {
|
||||
@@ -65,16 +61,16 @@ struct ExporterWithTarget {
|
||||
/// Handles the management of multiple file exporters.
|
||||
pub struct ExportManager {
|
||||
exporters: Vec<ExporterWithTarget>,
|
||||
metrics: Vec<MetricSelection>,
|
||||
primary: MetricSelection,
|
||||
}
|
||||
|
||||
impl ExportManager {
|
||||
/// Build the ExportManager that will export the results specified
|
||||
/// in the given ArgMatches
|
||||
pub fn from_cli_arguments(matches: &ArgMatches, metrics: &[MetricSelection]) -> Result<Self> {
|
||||
pub fn from_cli_arguments(matches: &ArgMatches, primary: MetricSelection) -> Result<Self> {
|
||||
let mut export_manager = Self {
|
||||
exporters: vec![],
|
||||
metrics: metrics.to_vec(),
|
||||
primary,
|
||||
};
|
||||
{
|
||||
let mut add_exporter = |flag, exporttype| -> Result<()> {
|
||||
@@ -124,7 +120,7 @@ impl ExportManager {
|
||||
/// order not to clutter the output of hyperfine with intermediate results).
|
||||
pub fn write_results(&self, results: &[BenchmarkResult], intermediate: bool) -> Result<()> {
|
||||
for e in &self.exporters {
|
||||
let content = || e.exporter.serialize(results, &self.metrics);
|
||||
let content = || e.exporter.serialize(results, self.primary);
|
||||
|
||||
match e.target {
|
||||
ExportTarget::File(ref filename) => {
|
||||
|
||||
+2
-2
@@ -15,10 +15,10 @@ fn get_output<E: Exporter + Default>(results: &[BenchmarkResult], unit: Option<U
|
||||
exporter
|
||||
.serialize(
|
||||
results,
|
||||
&[MetricSelection {
|
||||
MetricSelection {
|
||||
unit,
|
||||
..MetricSelection::default()
|
||||
}],
|
||||
},
|
||||
)
|
||||
.unwrap(),
|
||||
)
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ fn run() -> Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
let export_manager = ExportManager::from_cli_arguments(&cli_arguments, &options.metrics)?;
|
||||
let export_manager = ExportManager::from_cli_arguments(&cli_arguments, options.metrics[0])?;
|
||||
|
||||
let mut scheduler = Scheduler::new(&commands, &options, &export_manager);
|
||||
scheduler.run_benchmarks()?;
|
||||
|
||||
@@ -3,7 +3,6 @@ use std::process::Command;
|
||||
pub fn hyperfine_raw_command() -> Command {
|
||||
let mut cmd = Command::new(assert_cmd::cargo::cargo_bin!("hyperfine"));
|
||||
cmd.current_dir("tests/");
|
||||
cmd.env_remove("CLICOLOR_FORCE");
|
||||
cmd
|
||||
}
|
||||
|
||||
|
||||
@@ -44,25 +44,6 @@ fn runs_successfully() {
|
||||
.success();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_removed_reference_option_with_migration_guidance() {
|
||||
for args in [
|
||||
vec!["--reference", "echo reference", "echo comparison"],
|
||||
vec!["echo comparison", "--reference=echo reference"],
|
||||
vec!["--reference", "echo reference"],
|
||||
vec!["--reference"],
|
||||
] {
|
||||
hyperfine()
|
||||
.args(args)
|
||||
.assert()
|
||||
.code(2)
|
||||
.stdout("")
|
||||
.stderr(predicate::str::contains(
|
||||
"The --reference option has been removed. Put your reference command first instead.",
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn one_run_is_supported() {
|
||||
hyperfine()
|
||||
|
||||
Reference in new issue
Block a user