Last active
May 8, 2016 19:11
-
-
Save jurepolutnik/c798393238f34a7ddc8ca66bc25b036a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function count() { | |
var root = angular.element(document.querySelector('[ng-app]')).injector().get('$rootScope'); | |
var count = root.$$watchers ? root.$$watchers.length : 0; // include the current scope | |
var countScopes = 1; | |
var pendingChildHeads = [root.$$childHead]; | |
var currentScope; | |
while (pendingChildHeads.length) | |
{ | |
currentScope = pendingChildHeads.shift(); | |
while (currentScope) { | |
count += currentScope.$$watchers ? currentScope.$$watchers.length : 0; | |
countScopes ++; | |
pendingChildHeads.push(currentScope.$$childHead); | |
currentScope = currentScope.$$nextSibling; | |
} | |
} | |
console.log("#watchers = " + count); | |
console.log("#scopes = " + countScopes); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment