Commit Graph
147 Commits
Author SHA1 Message Date
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
sharkdp 46ad9bf39a Show error if numeric arguments can not be parsed
Shows an error message if the argument to options like '--warmup <N>'
can not be parsed:

    > hyperfine --warmup xxx "sleep 1"
    Error: Could not read numeric argument to '--warmup': invalid digit found in string

closes #337
2020-10-16 23:55:14 +02:00
sharkdp b2a246c195 Fix nan/inf output for very fast commands
closes #319
2020-10-16 11:00:49 +02:00
Stéphane Campinas 25f8129212 return an error if there are more name options than commands 2020-10-15 22:42:44 +02:00
Stéphane Campinas 0f0a109ca0 add CLI option to identify a command with a custom name
CLI option `--name` can be used to define the name to identify a
command. If not passed, then the command itself is used. Commands
and names are paired in the same order: The first command executed gets
the first name passed as option.

Close #326
2020-10-15 22:42:44 +02:00
sharkdp daf5ced498 Keep output colorized for 'full' and 'color' style
fixes #332
2020-10-15 21:54:57 +02:00
William Chargin f6464a2943 Support matrices of independent parameter lists
This patch permits the `-L`/`--parameter-list` argument to appear
multiple times. Each additional parameter increases the dimensionality
of the parameter matrix. One benchmark will be run for each combination
of parameters (i.e., the benchmark space is the Cartesian product of the
parameter spaces).

For now, `--parameter-list` and `--parameter-scan` are still mutually
exclusive. If desired, a follow-up change could similarly permit
multiple occurrences of `--parameter-scan` and also permit use of both
listed and scanned parameters together. (After all, `--parameter-scan`
can be thought of as syntactic sugar for a parameter list.)

This implementation is a little profligate with memory usage for
`BenchmarkResult`s: each result contains a separate copy of all
parameter names (as `String`s). This could be done away with by
threading lifetimes through the `BenchmarkResult`s, or by ref-counting
the names.

Because `BenchmarkResult`s now have maps with arbitrary key sets, we can
no longer use `serde` to serialize them to CSV. But a CSV writer is easy
to write by hand, so we just do that.

Fixes #253.

Test Plan:
Some unit tests included. As an integration test, try:

```
cargo run --release -- --runs 10 \
    -L foo foo1,foo2 -L bar bar9,bar8 \
    'echo {foo} {bar}' \
    'printf "%s\n" {foo} {bar}' \
    --export-csv /tmp/out
```

with all the export formats.

wchargin-branch: param-list-matrix
wchargin-source: 11051ab222c9de0fbc6ac6a080fbca48e05996c2
2020-10-13 14:00:46 +02:00
Andrii Radyk 9a064b7a8f remove deprecated Error::description 2019-12-19 21:55:16 +01:00