forEach vs loop (v21)

Revision 21 of this benchmark created on


Preparation HTML

<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.5/angular.min.js"></script>
<script src="http://sugarjs.com/current/sugar-full.min.js"></script>

Setup

var arr = [];
    for(var i = 0; i < 100000; i++) arr[i]=i;

Test runner

Ready to run.

Testing in
TestOps/sec
forEach
arr.forEach(function(v){v;});
ready
loop
for(var i = 0, l = arr.length; i < l; i++){arr[i];}
ready
underscore each
_.each(arr, function(v){v;});
ready
angular forEach
angular.forEach(arr, function(v){v;});
ready
sugarjs forEach
arr.each(function(v){v;});
ready

Revisions

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