underscore iterator

Benchmark created by Corban on


Preparation HTML

<script src="//documentcloud.github.com/underscore/underscore-min.js">
</script>
<script>
  var s1, s2, s3, s4;
  var iter = 100000;
  var bank = [];
  
  for (var i = 0; i < iter; i++) {
    bank[i] = Math.random();
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
for
for (var i = 0; i < iter; i++) {
  s4 = s3 * 8;
  s3 = s2 * 6;
  s2 = s1 * 4;
  s1 = bank[i] * 2;
}
ready
each
_(bank).each(function(val, i) {
  s4 = s3 * 8;
  s3 = s2 * 6;
  s2 = s1 * 4;
  s1 = val * 2;
});

 
ready

Revisions

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

  • Revision 1: published by Corban on