Skip to content

Add --filter-failed to exclude failed results from speed comparison#861

Open
tavian-dev wants to merge 3 commits intosharkdp:masterfrom
tavian-dev:feat/filter-failed
Open

Add --filter-failed to exclude failed results from speed comparison#861
tavian-dev wants to merge 3 commits intosharkdp:masterfrom
tavian-dev:feat/filter-failed

Conversation

@tavian-dev
Copy link
Copy Markdown

Summary

When using --ignore-failure with parameter scans, some parameter combinations may fail (non-zero exit code) and produce misleadingly fast times that skew the relative speed comparison. A command that errors out in 10ms shouldn't appear as "fastest" when comparing against commands that ran successfully for 2s.

This adds a --filter-failed flag that excludes benchmark results with any non-zero exit code from the relative speed comparison in the terminal summary output.

Usage

hyperfine --ignore-failure --filter-failed \
  --parameter-list size 100,1000,10000 \
  'my-tool --size {size}'

What it does

  • Adds BenchmarkResult::has_failure() method that checks for non-zero or missing exit codes
  • When --filter-failed is set, filters results before computing relative speeds in the summary
  • JSON/CSV exports are unaffected (they still contain all results with exit codes for post-processing)
  • If filtering leaves fewer than 2 results, the comparison is simply not shown

What it doesn't do

  • Does not modify --ignore-failure behavior — the two flags are independent
  • Does not affect intermediate benchmark output or export formats

Tests

  • 5 new tests: 4 for has_failure() edge cases, 1 for the filtering behavior in relative speed comparison

Closes #591

When using --ignore-failure with parameter scans, some parameter
combinations may fail (non-zero exit code) and produce misleadingly
fast times that skew the relative speed comparison. This adds a
--filter-failed flag that excludes results with non-zero exit codes
from the relative speed comparison in the summary output.

Closes sharkdp#591
When --filter-failed is used with --reference, the reference command
might itself have failures and get filtered. Previously this would
use the wrong command as reference. Now falls back to fastest_of
the remaining results.
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.

Excluding non-zero exit codes from Relative Time comparison.

1 participant