|
|
|
|
|
by psteeleidem
4143 days ago
|
|
This comparison benchmark was not designed to answer all of those questions. Perhaps just the following: "Does it scale well?" The conclusion from these tests is that React currently does not scale well on the server (at least for this type of page) due to high CPU and memory usage while requests per second were low for a very modest page of 100 search results items. This is not surprising since the focus of React has been on the client-side performance, but it is important because many projects are adopting React as an "isomorphic" solution. Hopefully the community and the authors of React can use this information to make React better. There is always something that can be learned from benchmarks like this. React does do a good job, but I also think Marko+Marko Widgets will be a much better fit for certain types of applications since it also includes a very strong UI component model and it is lighter. If nothing else, hopefully others can learn something from looking at the code and seeing two different approaches. |
|
Also this test could be more efficiently written. First (in SearchResults.jsx), setState accepts a callback in its second parameter, you don't need componentDidUpdate() or this.doneCallback (which is triggering more GC). Second in SearchResultsItem.jsx, you have an empty componentDidMount() function, you should get rid of that. Also this is super optimization, but it's also important that you think deeply about the creation of objects, therefore creating potential garbage that has to be cleaned up after short usage. In SearchResultsItem.jsx, you should just go with a className (className={"search-results-item" + (this.state.purchased && ' user-has-purchased')}) instead of a style object, which becomes useless if you don't have a purchase.
By giving each SearchResultsItem their own state management, you're making it more dirty than you has to be, it should just be a simple list item. Typically in this type of app (Search), the SearchResultsItem component would be stateless (no this.state, getInitialState). When someone clicks handleBuyButtonClick, that communicates the change to the store, which then flows down to SearchResults, which "re-renders" the list of SearchResultsItems.
There are probably a lot more optimizations I could go over, but in short conclusion React's performance is more than the library, it is a mode of thinking.