Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use raw executor by default, skip intermediate shell #487

Merged
merged 5 commits into from
Feb 22, 2022
Merged

Conversation

sharkdp
Copy link
Owner

@sharkdp sharkdp commented Feb 22, 2022

This adds a new "raw executor" (next to the "shell executor") that
allows hyperfine to execute commands directly without any intermediate
shell.

The command line is split into tokens (using the shell-words crate),
and according to POSIX rules. The first token is taken as the executable,
and the rest as arguments.

The new executor is enabled by default. In order to select the shell
executor, users will have to pass --shell=default.

This allows us to reduce measurement noise and to benchmark very quick
commands. It also decreases the time to run benchmarks, as we don't need
the calibration phase.

Also, it allows one to make sure that the executed command is not
implemented as a shell builtin. For example hyperfine true
and hyperfine --shell=default true return different times due
to the fact that bash executes true as a NOP.

Co-authored: Ciprian Dorin Craciun ciprian@volution.ro

To do:

  • Add more integration tests.
  • Think about whether we really want this as a default. Many use cases would not work out of the box (e.g. hyperfine "fd . ~"). And this could lead to surprising results: hyperfine "echo hi && sleep 0.1" would result in echo 'hi' '&&' 'sleep' '0.1'
  • Write CHANGELOG entry and update documentation.
  • Update --help text (regarding --shell=default and <command>)

This adds a new "raw executor" (next to the "shell executor") that
allows hyperfine to execute commands directly without any intermediate
shell.

The command line is split into tokens (using the `shell-words` crate),
and according to POSIX rules. The first token is taken as the executable,
and the rest as arguments.

The new executor is enabled by default. In order to select the shell
executor, users will have to pass `--shell=default`.

This allows us to reduce measurement noise and to benchmark very quick
commands. It also decreases the time to run benchmarks, as we don't need
the calibration phase.

Also, it allows one to make sure that the executed command is not
implemented as a shell builtin. For example `hyperfine true`
and `hyperfine --shell=default true` return different times due
to the fact that `bash` executes `true` as a NOP.

Co-authored: Ciprian Dorin Craciun <ciprian@volution.ro>
@sharkdp sharkdp merged commit d13454a into master Feb 22, 2022
@sharkdp sharkdp deleted the raw-executor branch February 22, 2022 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant