Comments (5)
Setup
RR stands for react-redux. RRR stands for reactive-react-redux.
4 scenarios:
- connect: RR 7.0.3
connect
HoC - hooks: RR 7.1.0
useSelecter
hook - rrr1: RRR 4.0.0-beta.0
useSelector
hook diff1.txt - rrr2: RRR 4.0.0-beta.0
useTrackedState
hook diff2.txt
Method
Use React Developer Tools Profiler in production build with webpack alias.
Before stating profiling: toggle "Only include drinks I can make from my bar" on to empty results
After starting profiling: Click the same toggle
Stop profiling after several seconds passed.
Finally, count the number of commits and sum up render duration. (I wonder if there's better way)
Results
connect: 14commits 0.8+0.7+0.2+0.1+0+0.1+16.1+0.1+100.2+13.1+0.1+0.1+0.1+0.6=132.3ms
hooks: 14commits 0.6+0.4+0.1+0.2+0+4.7+7.1+6+75+0.2+0.1+0+0+0.8=95.2ms
rrr1: 15commits 0.6+0.5+0.1+0.2+0.1+0+4.9+5.5+6+81.2+0.2+0+0.1+0+0.6=100.0ms
rrr2: 15commits 1+0.7+0.1+0.2+0.1+0+5.5+6.9+7.8+104.6+0.2+0.1+0.1+0.1+1.1=128.5ms
Now, I'm not sure if I'm doing anything wrong. This doesn't show any performance drop in connect vs hooks.
I swapped back/forth several times to make sure I wasn't imagining it and a quick check of the react devtools confirmed that many more re-renders were happening as a result of this change.
Maybe I'm missing to see how to count re-renders.
😕
from reactive-react-redux.
You can't see the animation janking? When I swap between branches it's really obvious that something's up with the hooks branch that isn't happening on the other one.
In terms of where I was counting, I was basically going into react devtools, doing a record, clicking/unclicking that filter, stopping recording and then checking the flame graph to see how many re-renders had occurred.
Pre change: 1 re-render for most components
post change: On some components it was upwards of 20
I am completely new to benchmarking react though (never had to worry about it before) so I may be using the tools incorrectly.
from reactive-react-redux.
You can't see the animation janking?
I don't think I'm seeing obvious things.
Just did checkout upgrade-redux-use-hooks
branch, npm install
and npm start
(DEV mode).
post change: On some components it was upwards of 20
Do you mean this Total renders
becomes 20? Doesn't seem to happen in my browser...
so I may be using the tools incorrectly.
So may I.
from reactive-react-redux.
That is the right branch - but I'm not seeing the number of renders I was any more either! I think I might be going mad. I swear it was showing 20+ renders.
There is definitely a jank when toggling that filter switch on this branch that isn't there on master but I'm not sure where this would be coming from - doesn't appear to be measurable in renders bizarrely which makes me wonder if it's actually some kind of blocking calculation rather than renders.
from reactive-react-redux.
Well, I actually wanted to see the issue for comparison, but it's good that there's no performance issue in react-redux hooks.
Thanks anyway. Please let me know if you find a way to reproduce it.
from reactive-react-redux.
Related Issues (20)
- Component not aware of state change? HOT 29
- Try new proxyequal HOT 19
- Stale props issue in selector API HOT 10
- Question: Ease of gradual transition to hooks concern HOT 3
- Add comparison with react-redux v7.1 in README
- Why calculateChangedBits = () => 0 HOT 16
- Discussions about proxy-polyfill HOT 1
- Benchmarking state usage tracking and other related projects HOT 5
- "Please use <Provider store={...}>..." exception unable to track down root cause HOT 3
- 'Please use <TrackedState...>' exception. Need help! HOT 6
- useTrackedState on an array does not trigger a rerender of FlatList with the extraData prop HOT 4
- Question about re-evaluation strategy HOT 9
- False negatives in tracking with React.memo
- A new API for reverting proxy
- Discussion: Antipattern to recommend `useTrackedSelector` HOT 4
- Testing Environment Slowdown HOT 4
- getUntrackedObject always returning null HOT 3
- SSR and `useLayoutEffect` issues warning in dev mode HOT 2
- Why is "patchStore" not exporte? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reactive-react-redux.