1.2.9: $rootScope.emit() vs $rootScope.$broadcast() (v56)

Revision 56 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.9/angular.min.js"></script>

<script>
angular
    .module("testApp",[])
    .controller("testController",function($rootScope, $scope) {

        window.$rootScope = $rootScope;
        var items = $scope.items = [];

        for (i=0;i<100;i++){
            items.push({
                number: i,
                text: 'some text'
            })
        }

    });
</script>

<div ng-app="testApp">
    <div ng-controller="testController">
        <ul>
            <li ng-repeat="item in items" ng-bind="item.number">
            </li>
        </ul>
    </div>
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
$broadcast
window.$rootScope.$broadcast('fooHappened');
ready
$emit
window.$rootScope.$emit('fooHappened');
ready

Revisions

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