Loop iteration (length comparison variations) + Set (v10)

Revision 10 of this benchmark created on


Preparation HTML

<script>let list = [1,2,3]</script>

Test runner

Ready to run.

Testing in
TestOps/sec
list.length
for (var i = 0; i < list.length; i++) {
    const fruit = list[i];
}
ready
pop
    while (list.length) {
        const fruit = list.pop();
         }
ready
while--
let i = list.length;
while (i--) {
        const fruit = list[i];
         }
ready
splice
let i = list.length;
while (i--) {
        const fruit = list.splice(i, 1);
    
}
ready
shift
while (list.length) {
     const fruit = list.shift();
    
}
ready
while++
let i = -1;
while (i++ < list.length -1) {
const fruit =list[i];
}
ready
while++ static
let i = -1;
let length = list.length;
while (i++ < length -1) {
const fruit = list[i];
}
ready

Revisions

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