Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
for loops vs forEach test: call functions from array with 4 items
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0
Browser:
Firefox 150
Operating system:
Linux
Device Platform:
Desktop
Date tested:
4 months ago
Benchmark engine:
Benchmark.js
forEach
22.6M/s
for...of
19.0M/s
for (C style)
17.3M/s
View exact numbers
Test name
Executions per second
✓
forEach
22,624,990 Ops/sec
for...of
18,979,604 Ops/sec
for (C style)
17,338,244 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
var functions = [ () => Math.random() + 10, () => Math.sqrt(Math.random() * 100), () => Math.floor(Math.random() * 50), () => Math.pow(Math.random(), 2), ];
Tests:
for...of
for (const fun of functions) fun();
for (C style)
for (let i = 0; i<functions.length; i++) functions[i]();
forEach
functions.forEach(fun => fun());