Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
for vs .foreach vs .some vs for..of
Compare loop performance
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36
Browser:
Chrome 91
Operating system:
Linux
Device Platform:
Desktop
Date tested:
10 months ago
Benchmark engine:
Benchmark.js
foreach
4.7M/s
some
4.7M/s
for
3.6M/s
for..of
925K/s
View exact numbers
Test name
Executions per second
✓
foreach
4,671,732 Ops/sec
some
4,670,880 Ops/sec
for
3,562,158 Ops/sec
for..of
924,512 Ops/sec
Script Preparation code:
let array = new Array(100);
Tests:
for
for (let i = 0; i < array.length; i++) { array[i]; }
foreach
array.forEach((i) => { array[i]; });
some
array.some((i) => { array[i]; });
for..of
for (let i of array) { array[i]; }