Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Test push spread map big vs simple push
(version: 0)
Comparing performance of:
spread vs push vs push simple for
Created:
2 years ago
by:
Registered User
Jump to the latest result
Script Preparation code:
var map1 = new Map(Array.from({ length: 1000 }, (_, index) => [`key${index}`, `value${index}`])); var map2 =new Map(Array.from({ length: 1000 }, (_, index) => [`key${index + 1000}`, `value${index + 1000}`]));
Tests:
spread
const keysFromMap1 = Array.from(map1.keys()); const keysFromMap2 = Array.from(map2.keys()); // Concatenate keys from both maps const allKeys = [...keysFromMap1, ...keysFromMap2]; console.log(allKeys);
push
const allKeys = []; // Add keys from map1 to allKeys for (const key of map1.keys()) { allKeys.push(key); } // Add keys from map2 to allKeys for (const key of map2.keys()) { allKeys.push(key); } console.log(allKeys);
push simple for
const allKeys = []; // Add keys from map1 to allKeys let i; const keys1 = map1.keys(), keys2 = map2.keys(); for (i = 0; i < keys1.length; i++) { allKeys.push(keys1[i]); } for (i = 0; i < keys2.length; i++) { allKeys.push(keys2[i]); } console.log(allKeys);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
spread
push
push simple for
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Comments
Confirm delete:
Do you really want to delete benchmark?