Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Loop methods
(version: 1)
Comparing performance of:
for vs for len vs while vs while len
Created:
one year ago
by:
Registered User
Jump to the latest result
Tests:
for
const arr = new Array(10000) for (let i = 0; i < arr.length; i++) { console.log(i); }
for len
const arr = new Array(10000) const len = arr.length for (let i = 0; i < len; i++) { console.log(i); }
while
let i = 0; const arr = new Array(10000) while (i < arr.length) { console.log(i); i++; }
while len
let i = 0; const arr = new Array(10000) const len = arr.length while (i < len) { console.log(i); i++; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
for
for len
while
while len
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
8 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 Edg/139.0.0.0
Browser/OS:
Chrome 139 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
for
47.5 Ops/sec
for len
46.4 Ops/sec
while
42.2 Ops/sec
while len
41.4 Ops/sec
Related benchmarks:
array iteration Large - continue
for-test
for-test1
test looping
destru vs for
For loop test #2
for [i,j] big/small ;
for tests
Array looping - for, Array.forEach, for-of, array.entries() - V2
Comments
Confirm delete:
Do you really want to delete benchmark?