Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
For Of vs Spread
Comparing the spread operater vs a for - of loop
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:143.0) Gecko/20100101 Firefox/143.0
Browser:
Firefox 143
Operating system:
Windows
Device Platform:
Desktop
Date tested:
7 months ago
Test name
Executions per second
Using For-Of Loops
23.2 Ops/sec
Using Spread
22.8 Ops/sec
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();