Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
for vs foreach vs for..of vs for..of over large entries 2
Compare loop performance
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/132.0.0.0 Safari/537.36
Browser:
Chrome 132
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
foreach
2K/s
for..of
2K/s
for
2K/s
View exact numbers
Test name
Executions per second
✓
foreach
1,885 Ops/sec
for..of
1,882 Ops/sec
for
1,840 Ops/sec
Script Preparation code:
const array = Array.from({length: 10000}); let t;
Tests:
for
for (let i = 0; i < array.length; i++) { t = array[i]; }
foreach
array.forEach((v) => { t = v; });
for..of
for (const v of array) { t = v; }