Commit Graph
154 Commits
Author SHA1 Message Date
David Peter d3d67fc908 Merge pull request #950 from Likio3000/codex/preserve-exports-on-invalid-options
Preserve export files when command options are invalid
2026-10-05 11:30:58 +02:00
David Peter a8e56efecc Use uom quantities for benchmark measurements 2026-10-05 10:32:32 +02:00
Eric Soler e2717c064e Preserve export files when command options are invalid 2026-10-03 15:09:02 +00:00
c0b3834277 Handle broken pipe errors on stdout gracefully (#932)
Replace `println!` calls on the results paths with `writeln!` on
`io::stdout()` and propagate the `io::Error` to `main`, where
`ErrorKind::BrokenPipe` is turned into a quiet `exit(0)`. This matches
the conventional behavior of command-line tools when their output pipe
is closed early (e.g. `hyperfine ... | head -n 0`), and fixes panics in
all run-output paths: the per-benchmark header and results, the speed
comparison summary, and `-`-style exports to stdout. The warnings and
"Note" outputs to stderr are converted the same way.


---------

Co-authored-by: Mathjk <Mathjk@users.noreply.github.com>
Co-authored-by: David Peter <mail@david-peter.de>
2026-10-02 11:18:56 +02:00
David Peter 038f369420 SortOrder field 2024-12-29 14:07:21 +01:00
David Peter 99d24b7a2e Multiple output policies 2024-11-11 22:24:25 +01:00
David Peter 2793d7b994 Do not export intermediate results to stdout, closes #640 2023-04-20 13:22:00 +02:00
Clemens Wasser ac8c114c80 Fix user and kernel times on Windows 2022-09-02 08:48:50 +02:00
David Peter f2f1dd9d40 Update dependencies 2022-02-22 14:04:07 +01:00
David Peter 0ffc6d7cc0 Move to timer module 2022-02-22 13:24:05 +01:00
David Peter f822455d99 Rename functions 2022-02-22 13:24:05 +01:00
David Peter 72d27729fa New Scheduler struct 2022-02-19 16:53:02 +01:00
David Peter a6baf49b72 Introduce Commands struct 2022-02-06 22:49:04 +01:00
David Peter c5a2266199 New schedule module 2022-02-06 20:19:50 +01:00
David Peter 5c634c9f2f Move a few modules to util 2022-02-06 20:19:50 +01:00
David Peter 999e7c4566 Move more modules around 2022-02-06 20:19:50 +01:00
David Peter 47091a5740 New parameter module 2022-02-06 20:19:50 +01:00
David Peter 865290a144 New output module 2022-02-06 20:19:50 +01:00
David Peter e5e4c8c020 New 'benchmark' module folder 2022-02-06 20:19:50 +01:00
David Peter cd38e9c63b Move build_commands 2022-02-06 20:19:50 +01:00
David Peter 33f8d03d6b Move build_export_manager to ExportManager 2022-02-06 20:19:50 +01:00
David Peter b54b2f81f4 Rename to Options 2022-02-06 20:19:50 +01:00
David Peter 39a85b88cf Move convert_cli_arguments_to_options to HyperfineOptions 2022-02-06 20:19:50 +01:00
David Peter c6477c7368 Rename function 2022-02-06 20:19:50 +01:00
David Peter 2040810ce3 Unified error handling 2022-02-06 20:19:50 +01:00
David Peter ce7087b107 Use thiserror for to derive Error 2022-02-06 20:19:50 +01:00
David Peter f5de5487cc Fix clippy suggestions 2022-02-06 17:47:40 +01:00
David Peter 80a9f51710 Update to clap 3 2022-02-03 21:07:15 +01:00
Ævar Arnfjörð Bjarmason 017d55a4a1 Add --setup (-s) option, like --prepare but runs once per batch
Add a --setup option for the use-case of wanting to do one-off setup
before a set of benchmarks, not the once-per-test setup that --prepare
does. This is useful for the cases noted in the updated documentation.

Per the feedback on https://github.com/sharkdp/hyperfine/pull/448 this
new "--setup" option will steal the "-s" short option from
"--style" (initially this was called "--build" and used the
non-conflicting "-b").

Potential future work:

I'd prefer if this and --cleanup took N number of commands, so you
could do e.g.:

    hyperfine -L rev master,next \
        -b 'git worktree add /tmp/test-{r}'  \
        -b 'make -C /tmp/test-{r} all'  \
	'make -C /tmp/test-{r} test' \
	-c 'git worktree remove /tmp/test-{r}'

I.e. a shortcut around not providing these with &&, which makes things
a bit more readable.

But the --cleanup option doesn't do that, so let's just go with what
it's doing for consistency, so for this you'll now need to do:

    hyperfine -L rev master,next \
        -b 'git worktree add /tmp/test-{r} &&
	    make -C /tmp/test-{r} all'  \
	'make -C /tmp/test-{r} test' \
	-c 'git worktree remove /tmp/test-{r}'
2021-11-16 21:36:35 +01:00
David Peter abd0d335ab Make stddev fields optional, hide "± σ" for 1 run 2021-11-14 10:28:24 +01:00
Ævar Arnfjörð Bjarmason bffd476128 Add support for one run with --runs=1
Extend the --runs=N option added in d78c33b (Added options to specify
the max/exact numbers of runs., 2018-09-09) to support --runs=1
instead of dying with a usage error.

This is useful to do ad-hoc testing of your commands while they might
still have syntax errors, or just for doing one run where you don't
care about the stddev.

Before:

    $ /usr/bin/hyperfine -s basic -r 1 -L n 5,10 'sleep 0.{n}'
    Error: Number of runs below two

After (-s basic) also works:

    $ hyperfine -r 1 -L n 5,10 'sleep 0.{n}'
    Benchmark 1: sleep 0.5
      Time (abs ≡):        500.6 ms               [User: 0.6 ms, System: 0.0 ms]

    Benchmark 2: sleep 0.10
      Time (abs ≡):        100.8 ms               [User: 0.7 ms, System: 0.0 ms]

    Summary
      'sleep 0.10' ran
        4.97 ± 0.00 times faster than 'sleep 0.5'

This likewise combines correctly with -m and -M, probably not very
useful, but if you're tweaking an existing command-line:

    $ hyperfine -m 1 -M 1 -L n 5,10 'sleep 0.{n}'
    Benchmark 1: sleep 0.5
      Time (abs ≡):        500.6 ms               [User: 0.5 ms, System: 0.0 ms]

    Benchmark 2: sleep 0.10
      Time (abs ≡):        100.6 ms               [User: 0.6 ms, System: 0.0 ms]

    Summary
      'sleep 0.10' ran
        4.98 ± 0.00 times faster than 'sleep 0.5'

The "± 0.00" output in "faster than" should probably be adjusted too,
or we could keep it for consistency. I didn't implement that because
this is the first time I do anything in Rust, and I ran out of
template to copy when wanting to quickly implement this in
write_benchmark_comparison() in main.rs.
2021-11-14 10:28:24 +01:00
David Peter 58d3eada61 Enable colors on Windows, closes #427 2021-10-17 18:03:18 +02:00
Heikki Hellgren f592155db7 Fix clippy warnings from tests 2021-10-17 17:04:46 +02:00
rhysd f2bfedd3a6 Fix clippy warnings 2021-10-17 17:03:36 +02:00
rhysd e2fdaceb9f Parse --shell option value as shell command 2021-10-17 17:03:36 +02:00
David Peter 1027940e3a Completely remove internal.rs 2021-08-24 22:44:08 +02:00
David Peter 76dd9d40f0 Move relative-speed computation to separate module 2021-08-24 22:44:08 +02:00
David Peter d5a2590b98 Move benchmark comparison to main.rs 2021-08-24 22:44:08 +02:00
David Peter eb31e0f5f9 Move tokenize to new file 2021-08-24 22:44:08 +02:00
David Peter 13986b17f4 Move progress bar to separate module 2021-08-24 22:44:08 +02:00
David Peter 30c381fe2a Flat directory/module structure 2021-08-24 22:44:08 +02:00
David Peter 465160b9aa Move Options struct to new module 2021-08-23 21:47:58 +02:00
David Peter eee32308b7 Move Command struct to new module 2021-08-23 21:47:58 +02:00
David Peter 068bebb4e6 Fix remaining clippy warnings 2021-08-22 16:33:43 +02:00
David Peter 85730b3f0f Auto-fix clippy warnings 2021-08-22 16:33:43 +02:00
Steven Gu 28e8c315dc Merges new and validate methods of RangeStep into one method, renames error names according to code review. 2021-07-27 22:34:38 +02:00
Steven Gu d4a0e9afb6 Fixes to limit --command-name count appear exactly once or same count with parameters. 2021-07-27 22:34:38 +02:00
Steven Gu 538dd06c16 Makes --comand-name take arguments from --parameter-list. 2021-07-27 22:34:38 +02:00
Martin Junghanns 990ed45c3a Create export file before first benchmark (#340) 2020-10-18 09:15:44 +02:00
Martin Junghanns d7e6fa6dfb Export intermediate results after each benchmark command 2020-10-18 09:13:56 +02:00