Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
for vs foreach vs some vs every vs for..of vs map
Compare loop performance
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0
Browser:
Firefox 133
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
for
13.7M/s
foreach
7.7M/s
some
6.3M/s
every
5.7M/s
map
4.7M/s
for..of
894K/s
View exact numbers
Test name
Executions per second
✓
for
13,738,457 Ops/sec
foreach
7,713,660 Ops/sec
some
6,339,842 Ops/sec
every
5,743,892 Ops/sec
map
4,701,418 Ops/sec
for..of
894,009 Ops/sec
Script Preparation code:
var array = new Array(100);
Tests:
for
for (var i = 0; i < array.length; i++) { array[i]; }
foreach
array.forEach(function(i) { array[i]; });
some
array.some(function(i) { array[i]; });
every
array.every(function(i) { array[i]; });
for..of
for (var i of array) { array[i]; }
map
array.map(a => a);