react-native icon indicating copy to clipboard operation
react-native copied to clipboard

fix:reduce-computations

Open admirsaheta opened this issue 1 year ago • 3 comments

Summary:

The pull request optimizes the canUseCachedMeasurement function in the Yoga library by reducing redundant computations, combining conditions where possible, and enhancing readability and performance. These changes aim to improve the efficiency of the function without altering its overall implementation or behavior.

Changelog:

[GENERAL][CHANGED] - Optimized the canUseCachedMeasurement function to reduce redundant computations and improve performance.

Test Plan:

  1. Unit Tests: Ran existing unit tests to ensure the optimized function produces the same results as before.
  2. Performance Tests: Conducted performance tests to measure the execution time of the canUseCachedMeasurement function before and after the optimization.
  3. Code Review: Reviewed the changes to ensure they maintain the original logic and correctness of the function.

The tests confirmed that the optimized function is more efficient while producing the same correct outputs.

admirsaheta avatar Jul 10 '24 12:07 admirsaheta

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 21,234,718 -6
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 24,431,915 -2
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: 8f98c58d384e71282a6147203bda84a095aba595 Branch: main

analysis-bot avatar Jul 10 '24 13:07 analysis-bot

This seems sane, but I'm curious how performance was measured and what difference was seen here. My assumption would be that the compiler would reuse the same math here.

NickGerleman avatar Jul 10 '24 20:07 NickGerleman

Could you please make this against the Yoga repo (https://github.com/facebook/yoga) instead of the React Native one? The two will sync when merged.

NickGerleman avatar Jul 10 '24 20:07 NickGerleman

@NickGerleman https://github.com/facebook/yoga/pull/1681 we can close this one 👍

admirsaheta avatar Jul 11 '24 09:07 admirsaheta