SIGN IN SIGN UP
facebook / react-native UNCLAIMED

A framework for building native applications using React

0 0 0 C++

Micro-optimise JavaScript part of Animated (#52906)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52906

changelog: [internal]

Micro-optimise JavaScript part of Animated by avoiding JS syntax for private variable/method - #foo. Instead, use double underscores. Benchmarks indicate ~10% improvement.

# Before
### Animated (mode 🚀) ###

| (index) | Task name                                                                    | Latency average (ns)  | Latency median (ns)      | Throughput average (ops/s) | Throughput median (ops/s) | Samples |
| ------- | ---------------------------------------------------------------------------- | --------------------- | ------------------------ | -------------------------- | ------------------------- | ------- |
| 0       | 'render 1 views'                                                             | '84990.06 ± 1.49%'    | '80691.00'               | '12164 ± 0.14%'            | '12393'                   | 11767   |
| 1       | 'render 10 views'                                                            | '373372.50 ± 1.00%'   | '363786.00'              | '2727 ± 0.26%'             | '2749'                    | 2679    |
| 2       | 'render 100 views'                                                           | '3099588.37 ± 0.92%'  | '3017559.00'             | '324 ± 0.74%'              | '331'                     | 323     |
| 3       | 'render 1 animated views (without animations set up)'                        | '174636.87 ± 0.67%'   | '168783.00'              | '5808 ± 0.17%'             | '5925'                    | 5727    |
| 4       | 'render 10 animated views (without animations set up)'                       | '1054481.51 ± 0.61%'  | '1036686.00'             | '953 ± 0.37%'              | '965'                     | 949     |
| 5       | 'render 100 animated views (without animations set up)'                      | '9176283.60 ± 1.12%'  | '8932316.00'             | '109 ± 0.95%'              | '112'                     | 109     |
| 6       | 'render 1 animated views (with a single animation set up - JS driven)'       | '204383.77 ± 0.52%'   | '199109.00'              | '4943 ± 0.17%'             | '5022'                    | 4893    |
| 7       | 'render 10 animated views (with a single animation set up - JS driven)'      | '1315894.97 ± 0.36%'  | '1300562.00 ± 40.00'     | '762 ± 0.30%'              | '769'                     | 760     |
| 8       | 'render 100 animated views (with a single animation set up - JS driven)'     | '11924031.45 ± 1.36%' | '11753334.50 ± 30040.50' | '84 ± 1.18%'               | '85'                      | 84      |
| 9       | 'render 1 animated views (with a single animation set up - native driven)'   | '318103.70 ± 0.37%'   | '311657.50 ± 0.50'       | '3162 ± 0.20%'             | '3209'                    | 3144    |
| 10      | 'render 10 animated views (with a single animation set up - native driven)'  | '2230305.96 ± 0.51%'  | '2191890.00'             | '449 ± 0.41%'              | '456'                     | 449     |
| 11      | 'render 100 animated views (with a single animation set up - native driven)' | '21983695.16 ± 0.75%' | '21945687.00 ± 17186.00' | '46 ± 0.74%'               | '46'                      | 64      |

# After

### Animated (mode 🚀) ###

| (index) | Task name                                                                    | Latency average (ns)  | Latency median (ns)     | Throughput average (ops/s) | Throughput median (ops/s) | Samples |
| ------- | ---------------------------------------------------------------------------- | --------------------- | ----------------------- | -------------------------- | ------------------------- | ------- |
| 0       | 'render 1 views'                                                             | '82684.75 ± 1.11%'    | '80231.00'              | '12331 ± 0.08%'            | '12464'                   | 12095   |
| 1       | 'render 10 views'                                                            | '378798.65 ± 1.16%'   | '365378.50 ± 9.50'      | '2703 ± 0.31%'             | '2737'                    | 2640    |
| 2       | 'render 100 views'                                                           | '3124253.51 ± 0.95%'  | '3039842.00'            | '322 ± 0.76%'              | '329'                     | 321     |
| 3       | 'render 1 animated views (without animations set up)'                        | '165580.70 ± 0.73%'   | '161562.00'             | '6131 ± 0.14%'             | '6190'                    | 6040    |
| 4       | 'render 10 animated views (without animations set up)'                       | '979127.10 ± 0.60%'   | '962509.50 ± 5.50'      | '1027 ± 0.36%'             | '1039'                    | 1022    |
| 5       | 'render 100 animated views (without animations set up)'                      | '8487740.98 ± 1.32%'  | '8235139.50 ± 3244.50'  | '118 ± 1.05%'              | '121'                     | 118     |
| 6       | 'render 1 animated views (with a single animation set up - JS driven)'       | '185333.93 ± 0.52%'   | '181582.00'             | '5451 ± 0.15%'             | '5507'                    | 5396    |
| 7       | 'render 10 animated views (with a single animation set up - JS driven)'      | '1145679.81 ± 0.37%'  | '1131668.00'            | '875 ± 0.29%'              | '884'                     | 873     |
| 8       | 'render 100 animated views (with a single animation set up - JS driven)'     | '10451056.69 ± 1.60%' | '10064069.50 ± 826.50'  | '96 ± 1.39%'               | '99'                      | 96      |
| 9       | 'render 1 animated views (with a single animation set up - native driven)'   | '292243.89 ± 0.40%'   | '286740.00'             | '3447 ± 0.21%'             | '3487'                    | 3422    |
| 10      | 'render 10 animated views (with a single animation set up - native driven)'  | '1993053.78 ± 0.47%'  | '1958960.00 ± 20.00'    | '503 ± 0.39%'              | '510'                     | 502     |
| 11      | 'render 100 animated views (with a single animation set up - native driven)' | '19528221.48 ± 0.95%' | '19383511.00 ± 7431.00' | '51 ± 0.92%'               | '52'                      | 64      |

Reviewed By: rubennorte

Differential Revision: D79179369

fbshipit-source-id: e641be0e8ec313b58bcae8330f127e707cd4fffc
S
Samuel Susla committed
f711d1776c986507d3e7885a37e7da081a90b00c
Parent: 0d3791c
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> on 7/30/2025, 9:49:37 AM