Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
for-vs-foreach
(version: 0)
Comparing performance of:
for vs foreach
Created:
2 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
const loop = 1000000; const list = [] for (let i=0; i<loop; ++i) list.push(i);
Tests:
for
for(let i=0,length=list.length; i<length; ++i) list[i] *= 2;
foreach
list.forEach((n, i) => { list[i] *= 2; });
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
for
foreach
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Comments
Confirm delete:
Do you really want to delete benchmark?