Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
for vs foreach bigger array
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
581K/s
foreach
150K/s
View exact numbers
Test name
Executions per second
✓
for
581,079 Ops/sec
foreach
150,163 Ops/sec
Script Preparation code:
var array = new Array(1000);
Tests:
for
for (var i = 0; i < array.length; i++) { array[i] = array[i] + i ; }
foreach
array.forEach(function(item, index) { return item = item +index; });