2016-02-20 02:03:16 +01:00
|
|
|
'use strict';
|
2017-09-14 03:48:53 +02:00
|
|
|
const common = require('../common.js');
|
|
|
|
const EventEmitter = require('events').EventEmitter;
|
2015-02-05 21:26:28 +01:00
|
|
|
|
2017-09-14 03:48:53 +02:00
|
|
|
const bench = common.createBenchmark(main, { n: [2e6] });
|
2015-02-05 21:26:28 +01:00
|
|
|
|
|
|
|
function main(conf) {
|
2017-09-14 03:48:53 +02:00
|
|
|
const n = conf.n | 0;
|
2015-02-05 21:26:28 +01:00
|
|
|
|
2017-09-14 03:48:53 +02:00
|
|
|
const ee = new EventEmitter();
|
2015-02-05 21:26:28 +01:00
|
|
|
|
|
|
|
for (var k = 0; k < 10; k += 1)
|
|
|
|
ee.on('dummy', function() {});
|
|
|
|
|
|
|
|
bench.start();
|
|
|
|
for (var i = 0; i < n; i += 1) {
|
|
|
|
ee.emit('dummy');
|
|
|
|
}
|
|
|
|
bench.end(n);
|
|
|
|
}
|