Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
tinybench demo: array iteration v2
Demo benchmark exercising the tinybench runner: compares three ways to sum an array.
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/153.0.0.0 Safari/537.36
Browser:
Chrome 153
Operating system:
Linux
Device Platform:
Desktop
Date tested:
yesterday
Benchmark engine:
tinybench
for loop
408K/s
forEach
282K/s
reduce
119K/s
View exact numbers
Test name
Executions per second
✓
for loop
408,403 Ops/sec
forEach
281,685 Ops/sec
reduce
119,287 Ops/sec
Script Preparation code:
var arr = Array.from({length: 1000}, function(_, i){ return i; });
Tests:
for loop
var s = 0; for (var i = 0; i < arr.length; i++) { s += arr[i]; }
forEach
var s = 0; arr.forEach(function(x){ s += x; });
reduce
var s = arr.reduce(function(a, b){ return a + b; }, 0);