Loop Test (v109)

Revision 109 of this benchmark created by Gabriel on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<script>
  var a = $('*').get(),
      b = _.extend({}, a),
      e;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery.each
$.each(a, function() {
  e = this;
})
ready
for loop
var len = a.length;

for (var i = 0; i < len; i++) {
  e = a[i];
}
ready
for without caching
for (var i = 0; i < a.length; i++) {
  e = a[i];
}
ready
alternative for loop
for (var i in a) {
  e = a[i];
}
ready
reverse for
var len = a.length;

for (var i = len; i--;) {
  e = a[i];
}
ready
while reverse
var i = a.length;
while (i) {
  e = a[--i]
}
ready
Underscore each
_.each(a, function() {
  e = this;
})
ready
jQuery.each over Object
$.each(b, function() {
  e = this;
})
ready
alternative for loop over Object
for (var i in b) {
  e = b[i];
}
ready
Underscore each over Object
_.each(b, function() {
  e = this;
})
ready

Revisions

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