AngularJS: digest

JavaScript performance comparison

Revision 61 of this test case created by

Preparation code

<script src="https://code.angularjs.org/1.0.2/angular.min.js"></script>
<script> angularBase = angular; angular = undefined;</script>

<script src="https://code.angularjs.org/1.2.26/angular.min.js"></script>
<script> angularLegacy = angular; angular = undefined;</script>

<script src="https://code.angularjs.org/1.3.3/angular.min.js"></script>
<script> angularLatest = angular; angular = undefined;</script>

<script>alightInitCallback = function(alight) { window.alight1 = alight }</script>
<script src="http://angularlight.org/bin/alight.last.min.js"></script>

<script>alightInitCallback = function(alight) { window.alight2 = alight }</script>
<script src="http://angularlight.org/bin/alight_0.7.42b.debug.js"></script>
      
<script>
Benchmark.prototype.setup = function() {
  function createScopeTree(angular, flag) {
    var rootScope;
    if(flag) rootScope = angular.Scope();
    else rootScope = angular.injector(['ng']).get('$rootScope');
  
    for(var i=0; i < 100; i++) {
      var child = rootScope.$new();
      for(var j=0; j < 100; j++) {
        child['a'+j] = {b:{c:1}};
        child.$watch('a'+j+'.b.c', function() {});
      }
    }
    return rootScope;
  }
  
  
  var baseScope = createScopeTree(angularBase);
  var legacyScope = createScopeTree(angularLegacy);
  var latestScope = createScopeTree(angularLatest);
  var ascope = createScopeTree(alight1, 1);
  var ascope2 = createScopeTree(alight2, 1);
  

};

Benchmark.prototype.teardown = function() {
  baseScope = null;
  legacyScope = null;
  latestScope = null;
  ascope = null;

};
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Angular 1.0.2
baseScope.$digest();
pending…
Angular 1.2.26
legacyScope.$digest();
pending…
Angular 1.3.3
latestScope.$digest();
pending…
Angular Light
ascope.$scan();
pending…
Angular Light + Object.observe
ascope2.$scan();
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL.

0 Comments