Skip to content

feat: add --run-sequentially to interleave benchmark runs (fixes #822)#889

Open
leno23 wants to merge 1 commit into
sharkdp:masterfrom
leno23:feat/run-sequentially-822
Open

feat: add --run-sequentially to interleave benchmark runs (fixes #822)#889
leno23 wants to merge 1 commit into
sharkdp:masterfrom
leno23:feat/run-sequentially-822

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 26, 2026

Summary

  • Adds --run-sequentially to interleave timing runs across multiple benchmark commands instead of completing all runs for one command before starting the next.
  • Preserves per-command statistics (mean, stddev, etc.) while executing rounds in pipeline order: cmd1, cmd2, cmd1, cmd2, …
  • Reference commands (--reference) still run as a separate full benchmark before the interleaved group, matching existing behavior.

Motivation

Fixes #822. Useful when:

  1. Benchmarking sequential pipeline steps that depend on each other
  2. Reducing temporal bias from varying system load by spreading runs across time

Example

hyperfine --run-sequentially --runs 3 './step1.sh' './step2.sh'

Executes:

./step1.sh
./step2.sh
./step1.sh
./step2.sh
./step1.sh
./step2.sh

Instead of the default grouped order (step1 ×3, then step2 ×3).

Test plan

  • cargo test (unit + integration + execution order tests)
  • New execution order test: benchmarks_are_executed_sequentially_with_run_sequentially_flag
  • New unit test in benchmark::sequential

When benchmarking multiple commands, hyperfine normally completes all
timing runs for one command before starting the next. The new flag runs
timing iterations in rounds across commands, which helps pipeline-style
workloads and reduces temporal load bias.

Fixes sharkdp#822

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5950cc1c23

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +52 to +53
for (benchmark, state) in benchmarks.iter().zip(states) {
results.push(benchmark.finalize(state)?);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Finalize each benchmark as soon as its last run completes

In sequential mode, finalize() (which runs --cleanup) is deferred until all commands finish, so a command that reaches its run count early is left uncleaned while later commands continue running. This contradicts the documented cleanup behavior (“after the completion of all benchmarking runs for each individual command” in src/cli.rs) and can change results when cleanup removes artifacts that affect subsequent rounds; it also means early-finished commands never get cleanup if a later command errors before the final loop.

Useful? React with 👍 / 👎.

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.

Run commands sequentialy instead of in groups.

1 participant