Skip to content

perf: bulk getRGB in binarisation — 35% faster, identical output - #3

Merged
konradkelly merged 2 commits into
mainfrom
perf/bulk-getrgb
Aug 13, 2026
Merged

konradkelly merged 2 commits into
mainfrom
perf/bulk-getrgb

Conversation

@konradkelly

Copy link
Copy Markdown
Owner

Recovers a commit that was sitting unmerged on the stale performance branch,
35 commits behind main, since 2026-06-02.

The change

DistanceImageBinarizer read each frame with getRGB(x, y) inside a nested
loop. Per-pixel access goes through the BufferedImage colour model on every
call, and this runs for every pixel of every frame of every video — it is the
hot path. Replaced with a single bulk getRGB(0, 0, width, height, …) into an
int[]. DfsBinaryGroupFinder.adjacentPixels is inlined in the same commit.

Measured

Full CLI run over videos/ensantina.mp4 — 478 seconds of footage, 11,477
frames:

Time
before (main) 4m47.7s
after 3m05.9s
35.4% faster (1.55x)

Output CSV is byte-for-byte identical between the two runs — same 11,477
rows, verified with diff. Full unit suite passes.

Also in this PR

While benchmarking I found the README claims the CSV has "one row per second".
It has one row per decoded frame — 11,477 rows over 478 seconds, roughly 24 per
second — and the sample rows showed integer timestamps where real output is
fractional. That was carried over from the original README. Corrected, and the
speedup above is now recorded in the architecture section.

The stale performance branch can be deleted once this merges.

The README said the output CSV has "one row per second". It has one row per
decoded frame — a 478-second clip produces 11,477 rows, about 24 per second —
and the sample rows showed integer timestamps where real output is fractional.
Pre-existing; carried over from the original README.

Also documents the bulk-getRGB change measured on that clip: 4m48s to 3m06s,
35% faster, byte-for-byte identical output.
@konradkelly
konradkelly merged commit db128d2 into main Aug 13, 2026
2 checks passed
@konradkelly
konradkelly deleted the perf/bulk-getrgb branch August 13, 2026 07:49
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