Skip to content

Count differing pixels without materializing them#2536

Merged
soulgalore merged 1 commit into
mainfrom
visualmetrics-compare-speedup
Jul 20, 2026
Merged

Count differing pixels without materializing them#2536
soulgalore merged 1 commit into
mainfrom
visualmetrics-compare-speedup

Conversation

@soulgalore

Copy link
Copy Markdown
Member

compare() is the hot path of frame processing — every duplicate-elimination, render-start and orange-frame check runs through it for every frame pair. It only needs the number of differing pixels, but argwhere materializes an index array of every matching pixel, which is most of the frame on every call. count_nonzero on the boolean mask returns the same number with no allocation. Verified byte-identical metrics on a real recording.

Co-authored-by: Claude Fable 5 noreply@anthropic.com
Change-Id: I2e5f31ee03f7c556d14a13937a659c2ebba58fe9

compare() is the hot path of frame processing — every
duplicate-elimination, render-start and orange-frame check runs
through it for every frame pair. It only needs the number of
differing pixels, but argwhere materializes an index array of every
matching pixel, which is most of the frame on every call.
count_nonzero on the boolean mask returns the same number with no
allocation. Verified byte-identical metrics on a real recording.

Co-authored-by: Claude Fable 5 noreply@anthropic.com
Change-Id: I2e5f31ee03f7c556d14a13937a659c2ebba58fe9
@soulgalore
soulgalore merged commit 0451419 into main Jul 20, 2026
17 checks passed
@soulgalore
soulgalore deleted the visualmetrics-compare-speedup branch July 20, 2026 07:06
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.

1 participant