Skip to content

Fix CSV export with --reference and parameter scans#868

Open
lawrence3699 wants to merge 1 commit intosharkdp:masterfrom
lawrence3699:fix/reference-csv-parameters
Open

Fix CSV export with --reference and parameter scans#868
lawrence3699 wants to merge 1 commit intosharkdp:masterfrom
lawrence3699:fix/reference-csv-parameters

Conversation

@lawrence3699
Copy link
Copy Markdown

Fixes #852.

Before this change, CSV export took parameter column names from only the first benchmark result. When --reference ran before a parameter scan, that first result had no parameters, so the header stopped at the timing columns and the first parameterized row failed with:

CSV error: found record with 9 fields, but the previous record has 8 fields

This collects parameter names across all results and writes empty cells for rows that do not have a value, so reference rows can be exported alongside parameterized benchmarks.

Validation:

  • cargo test export::csv::test_csv -- --nocapture
  • cargo test export::csv::test_csv_with_reference_row_before_parameterized_rows -- --nocapture
  • cargo fmt -- --check
  • cargo run -- --runs 1 --reference 'sleep 1' --parameter-scan secs 2 3 --export-csv /tmp/hyperfine-852.csv 'sleep {secs}'

Copilot AI review requested due to automatic review settings April 17, 2026 12:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a CSV export edge case where --reference results (with no parameters) could appear before parameterized benchmark results, causing inconsistent CSV column counts and a serialization error.

Changes:

  • Collect parameter names across all benchmark results to build a complete CSV header.
  • Emit empty CSV cells for parameter columns that are not present on a given row (e.g., reference rows).
  • Add a regression test covering the “reference row before parameterized rows” scenario.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

CSV error when using parameters with --reference

2 participants