sincecutoff.com
← all changes

hyperfine exposes iteration number to --prepare and --conclude

Introduced 2026-10-05 · score 0.95

HOW TO USE IT

When setup or cleanup must vary by benchmark iteration, read `$HYPERFINE_ITERATION` in a `--prepare` or `--conclude` command; the variable is zero-based. [v1.21.0 release notes](https://github.com/sharkdp/hyperfine/releases/tag/v1.21.0) [README](https://github.com/sharkdp/hyperfine/blob/v1.21.0/README.md)

hyperfine --prepare 'echo prepare-${HYPERFINE_ITERATION}' --conclude 'echo conclude-${HYPERFINE_ITERATION}' '<benchmark-command>'

WHY THIS HELPS

Make benchmark setup or cleanup commands vary their behavior by iteration.

REQUIREMENTS AND LIMITATIONS

  • Version: v1.21.0
  • --prepare <CMD...>: Runs CMD before each timing run; can be specified once for all commands or multiple times, once per benchmark command.
  • --conclude <CMD...>: Runs CMD after each timing run; can be specified once for all commands or multiple times, once per benchmark command.
  • $HYPERFINE_ITERATION: Zero-based iteration number exposed to the benchmarked command; v1.21.0 release notes state it is also exposed to --prepare and --conclude commands.
  • Prerequisite: Use hyperfine v1.21.0 or later for the documented release-note behavior.

FIRST-PARTY EVIDENCE

Check the installed version and the source before using it. Entry JSON

Report a problem with this card