Fix CSV export with --reference and parameter scans#868
Open
lawrence3699 wants to merge 1 commit intosharkdp:masterfrom
Open
Fix CSV export with --reference and parameter scans#868lawrence3699 wants to merge 1 commit intosharkdp:masterfrom
lawrence3699 wants to merge 1 commit intosharkdp:masterfrom
Conversation
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #852.
Before this change, CSV export took parameter column names from only the first benchmark result. When
--referenceran 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 fieldsThis 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 -- --nocapturecargo test export::csv::test_csv_with_reference_row_before_parameterized_rows -- --nocapturecargo fmt -- --checkcargo run -- --runs 1 --reference 'sleep 1' --parameter-scan secs 2 3 --export-csv /tmp/hyperfine-852.csv 'sleep {secs}'