Skip to content

Weight a unique function by its best match, not its last (#157) - #166

Merged
danielplohmann merged 2 commits into
danielplohmann:mainfrom
r0ny123:fix/157-unique-score-best-match
Sep 8, 2026
Merged

Weight a unique function by its best match, not its last (#157)#166
danielplohmann merged 2 commits into
danielplohmann:mainfrom
r0ny123:fix/157-unique-score-best-match

Conversation

@r0ny123

@r0ny123 r0ny123 commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Closes #157.

getUniqueFamilyMatchInfoForSample assigned the score-weighted bytes of a function on every match, so the value that survived was whichever match was iterated last, while the family and sample sets beside it were accumulated. The "unique" percentage on the 1-vs-N page was order-dependent. The assignment is max() now.

The test spreads the fixture's matches over different scores (the captured report scores every match of a function alike, which is why this went unnoticed), computes the expected best-per-function bytes for functions unique to one family, and checks the result in both iteration orders; it fails on main.

ruff, ty and the full suite pass.

getUniqueFamilyMatchInfoForSample assigned the score-weighted bytes of a
function on every match, so the value that survived was the match iterated
last rather than the best one, while the families and samples beside it
were accumulated. The "unique" percentage on the 1-vs-N result page was
therefore order-dependent (danielplohmann#157). The assignment is a max() now, and the
test checks the score against a fixture whose matches are spread over
different scores, in both iteration orders.
A function matched in several samples of its one family credited every
sample with its best score overall; the maximum is now per (function,
sample), which is what each sample's bytes are made of. Test covers two
differently scored samples of one family.
@danielplohmann
danielplohmann merged commit 06e67a4 into danielplohmann:main Sep 8, 2026
7 checks passed
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.

getUniqueFamilyScoreForSample keeps the last match's score, not the best

2 participants