Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
for-loop vs for-of perf test
Checking to see the performance differences of for-loop vs for-of
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36 OPR/109.0.0.0
Browser:
Opera 109
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
For-loop 100 Items
28980.2 Ops/sec
For-of 100 Items
2462573.5 Ops/sec
For-loop 1000 Items
2843.3 Ops/sec
For-of 1000 items
500169.8 Ops/sec
For-loop 1mil items
2.9 Ops/sec
For-of 1mil items
42.9 Ops/sec
HTML Preparation code:
<script> const listOfHundred = Array.from({ length: 100 }, (_, i) => i) const listOfThousand = Array.from({ length: 1000 }, (_, i) => i) const listOfMillion = Array.from({ length: 1_000_000 }, (_, i) => i) </script>
Tests:
For-loop 100 Items
let r = 0 for (let i = 0; i < listOfHundred.length; ++i) { r += listOfHundred[i] }
For-of 100 Items
let r = 0 for (const x of listOfHundred) { r += x }
For-loop 1000 Items
let r = 0 for (let i = 0; i < listOfThousand.length; ++i) { r += listOfThousand[i] }
For-of 1000 items
let r = 0 for (const x of listOfThousand) { r += x }
For-loop 1mil items
let r = 0 for (let i = 0; i < listOfMillion.length; ++i) { r += listOfMillion[i] }
For-of 1mil items
let r = 0 for (const x of listOfMillion) { r += x }