Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Native Event listener vs custom EventTarget vs fake listeners array
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 YaBrowser/24.7.0.0 Safari/537.36
Browser:
Yandex Browser 24
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Fake listeners array
74K/s
Native Event listener with callbacks array
27K/s
Custom EventTarget with callbacks array
27K/s
Custom EventTarget
579/s
Native Event listeners
523/s
View exact numbers
Test name
Executions per second
✓
Fake listeners array
73,581 Ops/sec
Native Event listener with callbacks array
26,829 Ops/sec
Custom EventTarget with callbacks array
26,658 Ops/sec
Custom EventTarget
579 Ops/sec
Native Event listeners
523 Ops/sec
Tests:
Native Event listeners
let i = 1001; const results = []; while (--i) { const index = i; window.addEventListener('custom:test', () => { results.push('Native Event listener ' + index); }, {once: true}); } window.dispatchEvent(new CustomEvent('custom:test', {bubbles: false}));
Native Event listener with callbacks array
let i = 1001; const callbacks = []; const results = []; while (--i) { const index = i; callbacks.push(() => { results.push('Fake listeners array ' + index); }); } window.addEventListener('custom:test', () => { results.push('Native Event listener ' + index); let i = callbacks.length; while (--i) callbacks[i](); }, {once: true}); window.dispatchEvent(new CustomEvent('custom:test', {bubbles: false}));
Custom EventTarget
let i = 1001; const target = new EventTarget(); const results = []; while (--i) { const index = i; target.addEventListener('custom:test', () => { results.push('Custom EventTarget ' + index); }, {once: true}); } target.dispatchEvent(new CustomEvent('custom:test', {bubbles: false}));
Custom EventTarget with callbacks array
let i = 1001; const callbacks = []; const target = new EventTarget(); const results = []; while (--i) { const index = i; callbacks.push(() => { results.push('Fake listeners array ' + index); }); } target.addEventListener('custom:test', () => { results.push('Native Event listener ' + index); let i = callbacks.length; while (--i) callbacks[i](); }, {once: true}); target.dispatchEvent(new CustomEvent('custom:test', {bubbles: false}));
Fake listeners array
let i = 1001; const callbacks = []; const results = []; while (--i) { const index = i; callbacks.push(() => { results.push('Fake listeners array ' + index); }); } i = callbacks.length; while (--i) callbacks[i]();