Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,21 @@ option:
hyperfine -L compiler gcc,clang '{compiler} -O2 main.cpp'
```

A common use case is comparing the same command across multiple Git branches. Use `--setup`
to switch branches once before each set of timing runs, so the branch switch is not part of
the measured command:
```sh
hyperfine \
--parameter-list branch main,performance-improvements \
--setup 'git switch {branch}' \
'rails runner true'
```

Make sure your working tree is clean before switching branches. Because this `--setup` command
changes the checkout, the repository will remain on the last branch from `--parameter-list`
after the benchmark finishes. If you want to benchmark uncommitted changes, consider using
`git worktree` and benchmarking the same command in each worktree instead.

### Intermediate shell

By default, commands are executed using a predefined shell (`/bin/sh` on Unix, `cmd.exe` on Windows).
Expand Down