listeners vs object manipulation

Benchmark created on


Setup

const listener = () => {};
const listenerList = [undefined, undefined, undefined];

Test runner

Ready to run.

Testing in
TestOps/sec
Listeners
document.addEventListener('click', listener);
document.removeEventListener('click', listener);
ready
Object
listenerList.push(listener);
const i = listenerList.findIndex(listener);
if (i >= 0) { records.splice(i, 1); }
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.