Angular JS Benchmark (v8)

Revision 8 of this benchmark created on


Description

Check angular js performance with and without splitting variables to smaller scopes.

Preparation HTML

<html ng-app>
<head>
<script src="http://code.jquery.com/jquery-1.7.2.min.js">
</script>
<script src="http://code.angularjs.org/angular-1.0.1.min.js">
</script>

<script>
var myApp = angular.module('myApp',[]);

var scope;
var scope2;

function MyCtrl($scope) {
    $scope.name = 'Superhero';
    $scope.data = [];
    scope = $scope;
}

function MyCtrl2($scope) {
    $scope.name = 'Superhero';
    $scope.data = [];
    scope2 = $scope;
}

function ANGClear(globalScope,data){
      globalScope.data.splice(0, ang_scope.data.length);
      globalScope.$apply();
}
      
function ANGPush(globalScope,data){          
       
      globalScope.data.push(data);
      globalScope.$apply();
}

</script>

</head>

<body>

<div ng-controller="MyCtrl">
  Hello, {{name}}!
    <span ng-repeat="item in data">{{item}} </span>
</div>

<div ng-controller="MyCtrl2">
  Hello, {{name}}!
    <span ng-repeat="item in data">{{item}} </span>
</div>


</body>
</html>

Test runner

Ready to run.

Testing in
TestOps/sec
1000 elems
$(function() {

  for (var i = 0; i < 1000; i++) {
    ANGPush("ngItem" + i);
  }

});
ready
500 elem, two controllers
for(var i=0;i<500;i++) {
         ANGPush(scope,"ngItem"+i);     
         ANGPush(scope2,"ngItem"+i);     
}         
ready

Revisions

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