for loop vs each loop (v4)

Revision 4 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<p>Test</p>
<p>Test</p>
<p>Test</p>
<p>Test</p>
<p>Test</p>
<p>Test</p>
<p>Test</p>
<p>Test</p>
<p>Test</p>
<p>Test</p>

Test runner

Ready to run.

Testing in
TestOps/sec
for
var elements = document.getElementsByTagName('p'),
    len = elements.length;

for (var i = 0; i < len; i++) {
 var element = elements[i];
}
ready
each
$('p').each(function() {
 var element = this;
});
ready

Revisions

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