Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
1000 x event listeners vs single event listener with array of 1000 callbacks
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:135.0) Gecko/20100101 Firefox/135.0
Browser:
Firefox 135
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
1000 event listeners
109.3 Ops/sec
1 event listener handling an array of 1000 callbacks
16831.9 Ops/sec
Tests:
1000 event listeners
let i = 1001; const results = []; while (--i) { const index = i; window.addEventListener('custom:test', () => { results.push(index); }, {once: true}); } window.dispatchEvent(new CustomEvent('custom:test'));
1 event listener handling an array of 1000 callbacks
let i = 1001; const results = []; const callbacks = []; while (--i) { const index = i; callbacks.push(() => { results.push(index); }) } window.addEventListener('custom:test', () => { callbacks.forEach((cb) => { cb() }) }, {once: true}); window.dispatchEvent(new CustomEvent('custom:test'));