r/angularjs • u/davidtranwd1 • Feb 17 '16
Is Angular 2 is faster ?
http://jslancer.com/2016/02/15/is-angular-2-is-faster/3
u/schippie Feb 17 '16
Is it just me or should this code really have used the async pipe in combination with an observable that just keeps emitting new values?
That might provide preformance improvements
1
u/davidtranwd1 Feb 19 '16
I won't use Observable for this demo because it's very simple. Angular 2 should be able to handle these simple operations well. And actually, with TrackBy, the performance of Angular 2 is improved.
3
u/mrpeabodynsherman Feb 17 '16 edited Feb 17 '16
Just a couple things:
Where have you heard that Angular 2 is Production ready? I'm not sure that's the case.
Also, you mention the most recent version being beta 3, but at the time of your positing the writing it's actually beta 6. In fact, you're using beta 6 in your example. Just simple corrections.
But I am really curious about that production thing. I haven't heard anywhere say that it's seriously ready for production.
edit: Here's the same scheme using RXJS Observables: http://pastebin.com/Vrrj25SN .. I'm not a pro, just working off what they teach you in the tutorials/guides + a simple observables tutorial. I have no means of testing it (crappy comp).
2
u/dvidsilva Feb 17 '16
Iirc performance is in the roadmap before production, there's a lot of optimization and things to add. The current beta shouldn't be used yet if performance is important to your app.
2
u/mrpeabodynsherman Feb 17 '16
Ya that was definitely my understanding as well. There's a moderately long road to go yet.
3
u/spritefire Feb 17 '16
This was proven the other day when it was pasted to the FB page the reason it's slower in this case is because the developer coded it wrong..
2
Feb 17 '16
I would love to see some commentary on this! Maybe its an Angular 2 problem, or the code could have been written in a more optimized way (for angular 2).
Also have you tried bench marking each piece to see where the slow down occurs?
Wonderful work by the way!
2
u/TheNiXXeD Feb 17 '16
I have an app currently in use in production that proved to be significantly faster in all ways. When I converted, I had to remove dozens of performance workarounds that were literally required for angular 1 to function with the amount of data I've got. After converting, I require none of the workarounds at all and it's actually still faster.
I suspect you've found a bug potentially, but I wouldn't call this some indication of overall performance loss.
1
u/bigdubb2491 Feb 17 '16
What do you think the results would have been had you utilized RxJS vs. setInterval, which I believe is the preferred way to handle these types of periodic events.
Also, just thinking about the test scenario you propose. 10000 iterations in 50ms with random getting called 3 times, per iteration. That's a shit ton of operations. Honestly, I don't think that either of them are keeping up with that frequently a UI gets updated. My guess is that Angular 2 is throttling this to keep things more efficient and lower burden on the UI.
Some JS benchmarks would be helpful as well.
-6
u/Capaj Feb 17 '16
I am not that surprised. Angular 2 is massive and it is always harder to optimize large codebase. Thankfully I switched to react last year.
3
u/spritefire Feb 17 '16
Except the reason it was slower due to bad code by the blogger not Angular2 itself.
12
u/EmptyTon Feb 17 '16
The Angular 2 version gets significantly faster with
trackBysupport. https://github.com/angular/angular/pull/6779When profiling with the chrome devtools timeline I get