• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common.js');
3
4const bench = common.createBenchmark(main, {
5  n: [1e6],
6  listeners: [1, 5, 10],
7}, { flags: ['--expose-internals'] });
8
9function main({ n, listeners }) {
10  const { EventTarget, Event } = require('internal/event_target');
11  const target = new EventTarget();
12
13  for (let n = 0; n < listeners; n++)
14    target.addEventListener('foo', () => {});
15
16  bench.start();
17  for (let i = 0; i < n; i++) {
18    target.dispatchEvent(new Event('foo'));
19  }
20  bench.end(n);
21
22}
23