In searching for potential bottlenecks in AngularJS I found this :
var KEYWORD_REGEX = /^((ng:|[$_a-z])[\w\-_]+)/;
KEYWORD_REGEX
seems to have a high call count as it’s called within loop :
_.forEach(tokens, function(token) { (line 72)
Which itself is within an inner loop :
_.forEach(doc, function(value, key) { (line 97)
Which is also within an inner loop ! :
_.forEach(docs, function(doc) { (line 88)
Se we have a nested loop two layers deep : O(N)^3 performance
This question : How Do I Measure the Performance of my AngularJS app's digest Cycle? suggests cpu profile run using Chrome dev tools to measure performance, but I don't think is granular enough to measure the performance of a specific section of code.
I'm not sure what code to write in order to hit this file. From reading the commend of file keywords.js :
* This processor extracts all the keywords from each document and creates
* a new document that will be rendered as a JavaScript file containing all
It seems any angular enabled file should invoke keywords.js as angularjs scan's every document for directives ? To measure performance an approach is run AngularJS from source , modify the loops described above to include timings (using getTime() ) which measures each loop to complete, create many AngularJS directives and run the app ?