Benchmarking a page or its controller

I recently inherited some AngularJS code (I cannot post the code) and noticed a huge delay on boot. This is completely unacceptable, and I need to optimize it. Using the chronology of Chrome, I noticed that there are many scenarios that do not really matter.

enter image description here

I tried using Batarang, but even the longest expression was just a date function and was insignificant compared to everything else. I have a feeling that his controller is incredibly greasy and spaghetti, and I need to somehow measure this controller or at least figure out what the bottleneck is before I start refactoring.

+6
source share
2 answers

What I finished just promised and subtracted the unix time difference to figure out how much time had passed. There are other tools like benchmarkjs, but that’s all I need to find out where the problem is.

var oldTime = (new Date).getTime(); deferred = $q.defer() deferred.promise.then(function() { # Code in here }).then(function() { console.log("Time taken: ", ((new Date).getTime() - oldTime)) }) deferred.resolve(); 
0
source

Try the open source Chrome Angular -performance plugin, you can compare specific controllers in Angular apps: https://github.com/Linkurious/angular-performance

0
source

Source: https://habr.com/ru/post/978862/


All Articles