Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
For Of vs Spread
(version: 1)
Comparing the spread operater vs a for - of loop
Comparing performance of:
Using For-Of Loops vs Using Spread
Created:
7 months ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
// Mock handler sets const navigationHandlers = Array.from({ length: 50000 }, (_, i) => [`nav-${i}`, () => i]); const titlebarHandlers = Array.from({ length: 50000 }, (_, i) => [`title-${i}`, () => i]); const tabHandlers = Array.from({ length: 50000 }, (_, i) => [`tab-${i}`, () => i]); function createSyncHandlerMap_loops() { const map = new Map(); for (const [msg, h] of navigationHandlers) map.set(msg, h); for (const [msg, h] of titlebarHandlers) map.set(msg, h); for (const [msg, h] of tabHandlers) map.set(msg, h); return map; } function createSyncHandlerMap_spread() { return new Map([ ...navigationHandlers, ...titlebarHandlers, ...tabHandlers, ]); }
Tests:
Using For-Of Loops
const map = createSyncHandlerMap_loops();
Using Spread
const map = createSyncHandlerMap_spread();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Using For-Of Loops
Using Spread
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
7 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:143.0) Gecko/20100101 Firefox/143.0
Browser/OS:
Firefox 143 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Using For-Of Loops
23.2 Ops/sec
Using Spread
22.8 Ops/sec
Related benchmarks:
Array.from vs Spread2
ak;ldjf;lakdjf
Test push spread map big
Array push spread vs Array.prototype.push.apply vs For loop
Spread vs Push3
Spread vs Push4
array.from vs spread on Map
Map. foreach
reduce + spread vs map + flat
Comments
Confirm delete:
Do you really want to delete benchmark?