11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common.js');
31cb0ef41Sopenharmony_ciconst EventEmitter = require('events').EventEmitter;
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst bench = common.createBenchmark(main, {
61cb0ef41Sopenharmony_ci  n: [2e6],
71cb0ef41Sopenharmony_ci  argc: [0, 2, 4, 10],
81cb0ef41Sopenharmony_ci  listeners: [1, 5, 10],
91cb0ef41Sopenharmony_ci});
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_cifunction main({ n, argc, listeners }) {
121cb0ef41Sopenharmony_ci  const ee = new EventEmitter();
131cb0ef41Sopenharmony_ci  ee.setMaxListeners(listeners + 1);
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci  for (let k = 0; k < listeners; k += 1)
161cb0ef41Sopenharmony_ci    ee.on('dummy', () => {});
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ci  switch (argc) {
191cb0ef41Sopenharmony_ci    case 2:
201cb0ef41Sopenharmony_ci      bench.start();
211cb0ef41Sopenharmony_ci      for (let i = 0; i < n; i += 1) {
221cb0ef41Sopenharmony_ci        ee.emit('dummy', true, 5);
231cb0ef41Sopenharmony_ci      }
241cb0ef41Sopenharmony_ci      bench.end(n);
251cb0ef41Sopenharmony_ci      break;
261cb0ef41Sopenharmony_ci    case 4:
271cb0ef41Sopenharmony_ci      bench.start();
281cb0ef41Sopenharmony_ci      for (let i = 0; i < n; i += 1) {
291cb0ef41Sopenharmony_ci        ee.emit('dummy', true, 5, 10, false);
301cb0ef41Sopenharmony_ci      }
311cb0ef41Sopenharmony_ci      bench.end(n);
321cb0ef41Sopenharmony_ci      break;
331cb0ef41Sopenharmony_ci    case 10:
341cb0ef41Sopenharmony_ci      bench.start();
351cb0ef41Sopenharmony_ci      for (let i = 0; i < n; i += 1) {
361cb0ef41Sopenharmony_ci        ee.emit('dummy', true, 5, 10, false, 5, 'string', true, false, 11, 20);
371cb0ef41Sopenharmony_ci      }
381cb0ef41Sopenharmony_ci      bench.end(n);
391cb0ef41Sopenharmony_ci      break;
401cb0ef41Sopenharmony_ci    default:
411cb0ef41Sopenharmony_ci      bench.start();
421cb0ef41Sopenharmony_ci      for (let i = 0; i < n; i += 1) {
431cb0ef41Sopenharmony_ci        ee.emit('dummy');
441cb0ef41Sopenharmony_ci      }
451cb0ef41Sopenharmony_ci      bench.end(n);
461cb0ef41Sopenharmony_ci      break;
471cb0ef41Sopenharmony_ci  }
481cb0ef41Sopenharmony_ci}
49