Closed guvenkaranfil closed 1 month ago
Latest commit: 6c6f88c27d3b922a9c26c37208d28cc77917fd09
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
I found something very interesting while testing the implementation @mdjastrzebski
For Unncessary Component
test, wrapping state updating inside a timeout cause not finding the unnecessary renders instead of updating directly.
const handlePress = () => { setCount((c) => c + 1); };
with setTimeOut
const handlePress = () => { setTimeout(() => setCount((c) => c + 1), 10); };
Another thing I came up with while testing is currently screen variable has been set in the outer scope.
On the first render screen variable is not set yet. On the second onRender
callback screen variable is being set. That means first two onRender
callbacks we can not do any comparison. So on the third callback can be comparasion because we have screen object and previously saved component representation
I am not sure I am missing any point you have described on the discussion issue @mdjastrzebski
@guvenkaranfil good first step. As a next step you should probably modify measurePerformance
function to capture the screen.toJSON()
trees (only for RN!) to some array during the first run. Then after the 1st run compare the consecutive JSON trees to find out if they are the same.
@mdjastrzebski I've just updated the implementation based on capturing component representations into an array and compare after.
Then after the 1st run compare the consecutive JSON trees to find out if they are the same.
Why not we would like to do comparison after 1st run instead of like end of the test like hasTooLateRender
@guvenkaranfil The comparison can be made after all runs, that is not that important.
The important factors are:
toJSON
tree during only the first count, and avoid capturing then during any subsequent runs in order not to affect the render times.warmupRuns: 1
is the default setup).@mdjastrzebski Have you had a chance to look updated parts 🤔
@guvenkaranfil Thanks for your patience. I'll try to check it soon.
Hello @mdjastrzebski, thanks for detailed feedback. I will follow up your comments and update accordingly. I believe with latest addition we show redundant render information both initial and update.
@mdjastrzebski Should we separate including redundant render information into markdown by types initial
and update
as we do right now for the console
Hi @mdjastrzebski, I believe it is better to put init
and update
. What do you think?
Hi @mdjastrzebski, Have you chance to look latest changes? I'd love to get update finalize the PR. Could you please tell me the steps we would need to take like adding additional tests to verify changes etc.
@guvenkaranfil Thank you for your patience with this PR, I didn't have time to work on it yet. From my perspective, I plan to merge it ~soon (before end of April), after doing final review and probably some minor tweaks by hand. You do not need to make any more changes.
@mdjastrzebski Is there anything to help to forward the PR?
@guvenkaranfil This PR will be merged, I just need to find some spare to review it properly.
@mdjastrzebski Okay thank you just let me know if you need me to update anything. I cant wait to use this feature to use my own projects
Slight progress: rebased to v1 branch, as v1 release is imminent
Does anyone know when the PR will be ready?
@brandon-gs I am still polishing the UX & implementation around it. Probably still need around a week or two. BTW this feature would be released as part of 1.0.0 (perhaps as RC release).
Name | Type | Duration | Count |
---|---|---|---|
fib 32 | function | 79.9 ms → 89.1 ms (+9.2 ms, +11.5%) 🔴 | 1 → 1 |
fib 31 | function | 49.1 ms → 54.1 ms (+5.0 ms, +10.2%) 🔴 | 1 → 1 |
There are no entries
Name | Initial Updates | Redundant Updates |
---|---|---|
Other Component 10 | 1 🔴 | - |
Other Component 10 legacy scenario | 1 🔴 | - |
Other Component 20 | 1 🔴 | - |
RedundantUpdates | - | 1 (1) 🔴 |
Async Component | 1 🔴 | - |
InitialRenders 1 | 1 🔴 | - |
InitialRenders 3 | 3 🔴 | - |
ManyRenderIssues | 2 🔴 | 2 (3, 4) 🔴 |
Name | Type | Duration | Count |
---|---|---|---|
InitialRenders 1 | render | 1.1 ms | 2 |
InitialRenders 3 | render | 1.4 ms | 4 |
ManyRenderIssues | render | 1.8 ms | 5 |
Name | Type | Duration | Count |
---|---|---|---|
RedundantInitialRenders 1 | render | 0.7 ms | 2 |
RedundantInitialRenders 3 | render | 0.6 ms | 4 |
Console version for the report:
🎉 This PR has been released in v1.0.0-rc.5 🎊
Summary
This draft PR is intended to start providing a way to detect unnecessary renders as described here
Test plan
I have added a test file called
UnneccassaryRender.perf-test
which is intended to unnecessarily render on the component and see the warning