native vs custom

Benchmark created on


Preparation HTML

<script src="https://unpkg.com/mitt/dist/mitt.umd.js"></script>

Setup

const emitter = window.mitt()
const results1 = [];
for (let i = 0; i < 1000; i++) {
	emitter.on('foo', e => {
		results1.push('Custom EventTarget ' + i)
		} )
};

const target = new EventTarget();
const results2 = [];
for (let i = 0; i < 1000; i++) {
  target.addEventListener('custom:test', () => {
  	results2.push('Custom EventTarget ' + i);
  });
};

Teardown


Test runner

Ready to run.

Testing in
TestOps/sec
MITT
emitter.emit('foo', new CustomEvent('custom:test', {bubbles: false}))
ready
native EventTarget
target.dispatchEvent(new CustomEvent('custom:test', {bubbles: false}));
ready

Revisions

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