Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
Flat vs forEach + push
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 YaBrowser/23.11.0.0 Safari/537.36
Browser:
Yandex Browser 23
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
forEach + push
61K/s
Flat
5K/s
View exact numbers
Test name
Executions per second
✓
forEach + push
60,816 Ops/sec
Flat
5,245 Ops/sec
Script Preparation code:
var myArray = []; var x = 2000; while (myArray.length < x) { myArray.push([{a: 'b'}]) }
Tests:
Flat
myArray .map((each) => { return each.map((deet) => { return { subject: deet.a }; }); }) .flat();
forEach + push
let newArr = [] myArray.forEach((each) => { return each.forEach((deet) => { newArr.push({ subject: deet.a }) }) })