-
Notifications
You must be signed in to change notification settings - Fork 469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I don't think you are comparing apples to apples. #3
Comments
@mhevery I very much appreciate the feedback - I know you guys are super busy. But, just to be clear, my intent was to look at a few different things:
For the That said, I do think that reversing the grid becomes very problematic because I am creating new object references: .... I am re-creating ROW references, which is probably destroying and recreating every single As far as TrackBy, it looks like it already landed in Beta 3 - I was just looking at it over the weekend: .... but, I think I maintain all the object references, the As an aside, I am really loving Angular 2 - it's definitely a lot to learn, but I actually really enjoy the new syntax. Really, it's not so different and there's not really that much to learn (about the syntax). I think it provides nice clarity. Much appreciated! |
Glad to hear, please update me, would love to hear the progress. Also, how do you make sure that the same DOM movements happen in React? |
@mhevery Ok, so fixing the reverse-grid algorithm, to keep the object identity references in tact, definitely sped up the rendering by like 30%. Beforehand, the reverse action was taking close to 300ms on average. Now, with the in-pace reverse with no DOM destruction (confirmed), it's close to the 200ms-230ms. So, clearly a big improvement. The ReactJS rendering time is still a bit faster on the reverse, coming in around 160ms-180ms time. But, definitely very close to each other. Video: http://www.screencast.com/t/uQq2irn3Y6v In the video you can see that I include optional logging of the TR and TD elements to confirm that the DOM elements are not destroyed on the reverse sort. Here is the commit to ensure the in-place changes: Thanks for your help. |
I still don't see trackBy here: https://github.com/bennadel/JavaScript-Demos/blob/master/demos/render-large-datasets-angular2-reactjs/angular.htm#L99 Also still don't think you are comparing same things. In case of React the react just updates in place, whereas Angular is trying to do the right thing, and move things around. If you want to make the two benchmarks same, then you should change Angular to track by position (like React)
|
We could make position tracking the default, but I feel that in that case we would be great at benchmarks but would be wrong in real world, such as for animation (something which react can't do out of the box). So it seems wrong that we should be doing things to make ourselves look fast at the expense of correctness. |
I am not sure that you are correct about the in-place editing for React. I think that - by default - it will update in place. But, my understanding is that when you start using From the React Documentation:
This is open to interpretation, but I think it means that React will move around the DOM instead of updating in place for the majority of the grid (my "ID" column doesn't have a key, so it probably is being updated in-place). As far as the |
The issue is that your
generateGrid
(https://github.com/bennadel/JavaScript-Demos/blob/master/demos/render-large-datasets-angular2-reactjs/angular.htm#L238) method creates new set of objects each time it runs. Angular 2 then has to remove the DOM and recreate all of the items for the purposes of animation. So the Angular perf test is doing a lot more then it should.There are two ways to fix it:
gerenerateGrid
to return an array with same identities.*ngFor
(https://github.com/bennadel/JavaScript-Demos/blob/master/demos/render-large-datasets-angular2-reactjs/angular.htm#L88) to usetrackBy
See: https://github.com/angular/angular/blob/master/modules/angular2/src/common/directives/ng_for.ts#L86 (It will be in beta4)Tho above should make Angular significantly faster.
More reading: mathieuancelin/js-repaint-perfs#19
The text was updated successfully, but these errors were encountered: