angular_react_directive_example icon indicating copy to clipboard operation
angular_react_directive_example copied to clipboard

Several performance updates to the Angular 1 version

Open lgalfaso opened this issue 10 years ago • 5 comments

Added several performance fixes to the Angular 1 version

lgalfaso avatar Mar 08 '15 22:03 lgalfaso

Thanks for looking into the performance of this demo.

Your most significant change is the localApply = false for the call to $timeout with a local digest. I specifically chose not to do that for this demo because this was meant to simulate an AJAX request with $http, which does not provide a localApply feature.

This demo was meant to be representative of Angular apps in general, which are usually not designed to keep track of which scopes changed, because Angular 1 encourages global digest.

TL;DR As you show, Angular 1 is not inherently slow. This demo, along with virtually any Angular 1 app, could be optimized to be fast, but app developers would have to depart from idiomatic Angular code to do so.

djsmith42 avatar Mar 08 '15 23:03 djsmith42

@lgalfaso Also, did you see any improvement to the initial load speed with these changes? I do not.

djsmith42 avatar Mar 08 '15 23:03 djsmith42

The initial built of the table is about the same with or without the changes. If the random timeout is set to 10 (or 0) then the loadAll performance is comparable with react (or slightly better). Note that the fact that $timeout is a promise was used and this is also true for $http. On the other side, it is true that global digests are recommended (or at least what most people use)

lgalfaso avatar Mar 09 '15 00:03 lgalfaso

Agreed on all points.

This demo showed two things:

  1. Initial DOM loading in Angular 1 is slow.
  2. Global digests are slow.

I think it showed those points well enough, and while there are good solutions for #2, there are basically no solutions for #1 to my knowledge. Do you know of any?

djsmith42 avatar Mar 09 '15 00:03 djsmith42

I do not know if I would call them "good", I would just say that there are solutions for #2 if you know what you are doing. For #1 there are solutions too, but none that I know of that would keep the code easy to read

lgalfaso avatar Mar 09 '15 00:03 lgalfaso