Add a simple but reasonably fast Redux version
It's less efficient than V3 but also way simpler. Relies on memoization of props (which is something you want to do in intensive apps).
This gives me ~20ms for going through 32K nodes which IMO is good enough for most real apps.
I used [email protected] because it is the latest stable version and the one I optimized. I haven't participated in the 5.x effort and can't say if it is optimal for this scenario (but it does seem 1.5-2x slower).
Very nice. Would love to hear @jimbolla 's thoughts on the perf difference between 4.4.6 and 5.0.
@markerikson I'm not sure what I'm looking at here.
@jimbolla : per Dan's comments at https://www.reddit.com/r/reactjs/comments/5hf4d4/an_artificial_example_where_mobx_really_shines/ and https://twitter.com/dan_abramov/status/807320728706150400 , the original version of this benchmark apparently was already using react-redux@next. Dan's new variation of this benchmark switched back to 4.4.6, and that plus the use of mapState factories made things faster.
Basically I'm curious if v5 actually makes things better or worse overall in variations on this benchmark.
Thanks @gaearon for joining in!
Seems scripting takes about 20% of the run time, so it’s much better than V1 and V2.
@markerikson The reason I use react-redux@next is because of this line in master: the !this.doStatePropsDependOnOwnProps which says that if the computed state depended on own props, don’t early return.
This causes 32,768 components to go through React’s update cycle and end up with shouldComponentUpdate. This takes up a significant amount of time. By memoizing (using the initialProps instead of ownProps), this enables early return which is where perf gain came from. Somehow, it is slower in v5.
I think v5 might be faster for general case but slower for a stress test like this. Not sure.
The pattern where mapStateToProps = (initialState, intialProps) => (justState) => results is the known case where v4 is faster than v5. v4's alogrith works really well for that usage. v5 benefits more from the mapStateToProps = (state, props) => results usage.
Coming across the topic more than a year later - are the findings still the status quo? An update would be great! :)
I don't think anything has meaningfully changed.... yet. You may want to look at the React-Redux roadmap I put up for discussion in https://github.com/reduxjs/react-redux/issues/950 .