function countWatchers() {
    // jshint validthis: true
    var count = this.$$watchers ? this.$$watchers.length : 0; // include the current scope
    var pendingChildHeads = [this.$$childHead];
    var currentScope;

    while (pendingChildHeads.length) {
      currentScope = pendingChildHeads.shift();

      while (currentScope) {
        count += currentScope.$$watchers ? currentScope.$$watchers.length : 0;
        pendingChildHeads.push(currentScope.$$childHead);
        currentScope = currentScope.$$nextSibling;
      }
    }

    return count;
  }
@ngdoc method
@name $rootScope.Scope#$countWatchers
@module ngMock
@description
Counts all the watchers of direct and indirect child scopes of the current scope.

The watchers of the current scope are included in the count and so are all the watchers of
isolate child scopes.

@returns {number} Total number of watchers.