Nested Fors vs. Iterative fors (v2)

Revision 2 of this benchmark created by SV on


Description

Nested Loops example updated.

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script src="https://raw.github.com/documentcloud/underscore/master/underscore-min.js"> </script>
<script>
  var range = _.range(100),
      total_runs = _.range(10);
  
  function doSomething(a) {
    a * 10 + a * 1000000.0 / 50.0;
  }
  
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
one hundred iterations with ten function calls each
_.each(range, function(a) {
  doSomething(a);
  doSomething(a);
  doSomething(a);
  doSomething(a);
  doSomething(a);
  doSomething(a);
  doSomething(a);
  doSomething(a);
  doSomething(a);
  doSomething(a);
});
ready
one hundred iterations ten times with one call each
_.each(total_runs, function(a) {
    _.each(range, doSomething);
});
ready

Revisions

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