Separate the comparison engine from the reporter#90
Merged
KaykCaputo merged 1 commit intoJul 25, 2026
Merged
Conversation
compare_traces() computed and printed at once, so any new output format had to re-implement comparison logic. It is now pure and returns a richer ComparisonData: per-function deltas with explicit statuses (regression / improvement / stable / new / removed / no_signal / no_baseline), plus improvements, new/removed function lists and the threshold used. All rich printing moves to a new display.py (print_comparison), which also takes over the only-regressions filtering — filtering is a display concern. cli.py wires compare -> display at both call sites. No new flags, no behavior change: RegressionData and has_regression keep their shape and the terminal output is byte-identical. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
KaykCaputo
approved these changes
Jul 25, 2026
KaykCaputo
left a comment
Owner
There was a problem hiding this comment.
Perfect, just as i imagined
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.
Second slice from #80 — the one you said you were most excited about. Pure refactor: no new flags, no behavior change, identical output.
What changes
compare_traces()used to compute and print at the same time, which meant any new output format would have to re-implement the comparison logic (or re-parse printed text). Now:compare.pyis pure — noprint, no side effects. It returns a richerComparisonData:Each
FunctionDeltacarriesname,status,old_time,new_time,percent. Statuses are module-level constants:regression/improvement/stable/new/removed/no_signal/no_baseline— the states the old code expressed only as printed strings.display.pyis new and owns allrichprinting:print_comparison(comparison, only_regressions=False). Theshow_only_regressionsargument moved from the comparison function to the display function, which is where filtering actually belongs.cli.pynow doescompare_traces(...)→print_comparison(...). Both call sites (--compareandbaseline compare) updated.Why this ordering matters
This is the enabler for the Markdown reporter (next PR): with comparison results as data, a reporter is ~100 lines consuming
ComparisonData, and the same is true for anything after it — JUnit, the HTML comparison column, whatever comes later. None of them need to know how a regression is decided.RegressionDataandhas_regressionkeep their shape, so any external consumer of the current API keeps working.Verification
test_compare.pynow asserts on returned data (including a test that comparison produces no output at all), and the printing assertions moved to a newtest_display.py— same expectations, same strings, just pointed at the display layer.(+N.NN%)formatting.--compareoutput before and after the refactor: identical, down to blank lines and colors.test_symlinked_user_code, which needs Windows symlink privileges and passes on CI).🤖 Generated with Claude Code