Add --extra-metadata support to compare_to command
Summary
This pull request adds support for a new --extra-metadata argument to the compare_to command. It allows users to include selected metadata keys as additional columns in the comparison table output.
Motivation
The current compare_to output does not show metadata values such as CPU model, OS version, Python build info, etc. This feature was requested in Issue #162 (“Display additional information through table”) to make analysis more informative.
What This PR Does
Adds a new CLI flag: --extra-metadata "key1,key2,..."
Passes metadata keys into _compare.py
Updates table generation to show metadata for both reference and changed benchmarks
Ensures geometric mean rows remain aligned
Testing
Manually tested using sample benchmark files
Verified table output for:
No metadata requested
Single metadata key
Multiple metadata keys
Mixed significant / non-significant benchmarks
Notes
Feedback is welcome! I’m happy to update the PR if changes are needed.
Hi! @vstinner I’ve pushed the updated changes to the add-extra-metadata branch. Here’s what I did:
Integrated the --extra-metadata feature cleanly into the existing compare_to flow.
Fixed implementation issues that caused errors when formatting metadata output.
Resolved merge conflicts during branch sync and ensured the final code reflects only the correct logic.
Added a dedicated test file: pyperf/tests/test_extra_metadata.py
Verified full test suite — all tests pass successfully (174 passed).
Ensured that:
Baseline behavior of compare_to is unchanged
Metadata output only appears when explicitly requested
No regressions in table, CLI, verbose, or non-significant cases.
Updated the PR branch cleanly using cherry-pick without opening a new PR.
Happy to make any additional adjustments if required!
Hi @vstinner , thanks for the review!
I have addressed all your comments:
Moved the test to pyperf/tests/test_perf_cli.py and used the existing create_bench helper.
Fixed the merge conflict in main.py and cleaned up the argument definition.
Fixed the code style in _compare.py (indentation, comments, and line wrapping) as requested.
Tests are passing locally. Please let me know if there is anything else!