Underscore.each vs jQuery.each vs. for loop vs. nimble-foreach (v199)

Revision 199 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script src="//documentcloud.github.com/underscore/underscore-min.js">
</script>
<script>
  var pi = Math.PI,
      a = {
      a: 1,
      b: 2,
      c: 3,
      d: 4,
      e: 5,
      f: 6,
      g: 7
      },
      e;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery.each
$.each(a, function(k, v) {
  a[k]++;
});
ready
good old for loop
for (var k in a) {
  if (a.hasOwnProperty(k)) {
    a[k]++;
  }
};
ready
object.keys.foreach
Object.keys(a).forEach(function(element, index, array){
a[element]++;
});
ready

Revisions

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