AngularJS: digest

JavaScript performance comparison

Revision 73 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.14/angular.min.js"></script>
<script> angularLatest = angular; angular = undefined;</script>

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

<script>alightInitCallback = function(b) { window.alight84=b() }</script>
<script src="http://angularlight.org/bin/alight_0.8.4.min.js"></script>

<script>alightInitCallback = function(b) { window.alight821=b() }</script>
<script src="http://angularlight.org/bin/alight_0.8.21.min.js"></script>

      
<script>
Benchmark.prototype.setup = function() {
  function createScopeTree(angular, flag, useObserver) {
    var rootScope;
    if(flag) rootScope = angular.Scope({useObserver: useObserver});
    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() {});
      }
    }
    if(useObserver) rootScope.$scan();
    return rootScope;
  }
  
  
  var baseScope = createScopeTree(angularBase);
  var legacyScope = createScopeTree(angularLegacy);
  var latestScope = createScopeTree(angularLatest);
  var ascope7 = createScopeTree(alight7, 1);
  var ascope821 = createScopeTree(alight821, 1);
  var ascope84o = createScopeTree(alight84, 1, true);
  var ascope821o = createScopeTree(alight821, 1, true);
  

};

Benchmark.prototype.teardown = function() {
  baseScope = null;
  legacyScope = null;
  latestScope = null;
  ascope7 = null;
  ascope821 = null;
  ascope84o = null;
  ascope821o = 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.14
latestScope.$digest();
pending…
Angular Light 0.7
ascope7.$scan();
pending…
Angular Light 0.8
ascope821.$scan();
pending…
Object.observe + Angular Light 0.8.4
ascope84o.$scan();
pending…
Object.observe + Angular Light 0.8.21
ascope821o.$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