jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
Cost of Angular's $watchCollection vs $watch
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.js"></script>
<script>
var app = angular.module('app', []);
var deregs = [];
app.run(function($rootScope) {
$rootScope.data = [
'bob', 'frank', 'jerry', 'bargle',
'bob', 'frank', 'jerry', 'bargle',
'bob', 'frank', 'jerry', 'bargle',
'bob', 'frank', 'jerry', 'bargle'
];
});
app.service('Watch', function($rootScope) {
return {
run: function() {
deregs.push($rootScope.$watch('data', function(n, o) {
}));
$rootScope.$digest();
}
};
});
app.service('WatchCollection', function($rootScope) {
return {
run: function() {
deregs.push($rootScope.$watchCollection('data', function(n, o) {
}));
$rootScope.$digest();
}
};
});
</script>
<div id="myApp" ng-app="app"></div>
var i = angular.element(document.getElementById('myApp')).injector();
angular.forEach(deregs, function(d) {
d();
});
Ready to run.
Test | Ops/sec | |
---|---|---|
$watch |
| ready |
$watchCollection |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.