Skip to content

chore: improve ImageAssert.AreSimilarAsync perf#22695

Open
Xiaoy312 wants to merge 1 commit intomasterfrom
dev/xygu/20260219/image-assert-perf
Open

chore: improve ImageAssert.AreSimilarAsync perf#22695
Xiaoy312 wants to merge 1 commit intomasterfrom
dev/xygu/20260219/image-assert-perf

Conversation

@Xiaoy312
Copy link
Contributor

GitHub Issue: n/a

PR Type: 🔄 Refactoring (no functional changes, no api changes)

What is the current behavior? 🤔

What is the new behavior? 🚀

dont access the same pixel multiple times during ImageAssert.AreSimilarAsync

Copilot AI review requested due to automatic review settings February 19, 2026 17:51
@Xiaoy312 Xiaoy312 enabled auto-merge February 19, 2026 17:51
@Xiaoy312 Xiaoy312 disabled auto-merge February 19, 2026 17:52
@Xiaoy312 Xiaoy312 enabled auto-merge February 19, 2026 17:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes the ImageAssert.AreSimilarAsync method by caching pixel values before performing calculations, reducing redundant indexer calls during image comparison. The RawBitmap indexer performs scaling calculations, array offset computation, and Color object construction, making repeated accesses expensive. By caching each pixel value once instead of accessing it three times, this change improves performance in a hot loop that processes every pixel in the image.

Changes:

  • Cache expected[x, y] and actual[x, y] pixel values before calculations
  • Use cached pixel values for RGB and alpha component calculations, reducing indexer calls from 6 to 2 per pixel

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@unodevops
Copy link
Contributor

🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22695/wasm-skia-net9/index.html

@Xiaoy312 Xiaoy312 force-pushed the dev/xygu/20260219/image-assert-perf branch from 349bbf1 to e5f4427 Compare February 19, 2026 19:03
@Xiaoy312 Xiaoy312 changed the title chore: improve ImageAssert.AreSimilarAsync pref chore: improve ImageAssert.AreSimilarAsync perf Feb 19, 2026
@unodevops
Copy link
Contributor

🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22695/wasm-skia-net9/index.html

@unodevops
Copy link
Contributor

⚠️⚠️ The build 197203 has failed on Uno.UI - CI.

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.

3 participants

Comments