Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
for vs foreach vs for..in vs for..of, 1m
Compare loop performance with a small load
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:152.0) Gecko/20100101 Firefox/152.0
Browser:
Firefox 152
Operating system:
Windows
Device Platform:
Desktop
Date tested:
28 days ago
forEach
278/s
for-in
31/s
for-i
15/s
for-of
15/s
View exact numbers
Test name
Executions per second
✓
forEach
278 Ops/sec
for-in
31 Ops/sec
for-i
15 Ops/sec
for-of
15 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const array = new Array(1000000); for (let i = 0; i < array.length; i++) { array[i] = Math.random() * 1000; }
Tests:
for-i
for (let i = 0; i < array.length; i++) { const value = array[i]; const str = value.toString(10); }
forEach
array.forEach((value) => { const str = value.toString(10); });
for-in
for (const i in array) { const value = array[i]; const str = value.toString(10); }
for-of
for (const value of array) { const str = value.toString(10); }