2016-02-20 09:03:16 +08:00
|
|
|
'use strict';
|
2014-12-20 07:04:35 +08:00
|
|
|
var common = require('../common.js');
|
|
|
|
var events = require('events');
|
|
|
|
|
|
|
|
var bench = common.createBenchmark(main, {n: [25e4]});
|
|
|
|
|
|
|
|
function main(conf) {
|
|
|
|
var n = conf.n | 0;
|
|
|
|
|
|
|
|
var ee = new events.EventEmitter();
|
|
|
|
var listeners = [];
|
|
|
|
|
2016-02-28 13:56:18 +08:00
|
|
|
var k;
|
|
|
|
for (k = 0; k < 10; k += 1)
|
2014-12-20 07:04:35 +08:00
|
|
|
listeners.push(function() {});
|
|
|
|
|
|
|
|
bench.start();
|
|
|
|
for (var i = 0; i < n; i += 1) {
|
2016-02-28 13:56:18 +08:00
|
|
|
for (k = listeners.length; --k >= 0; /* empty */)
|
2014-12-20 07:04:35 +08:00
|
|
|
ee.on('dummy', listeners[k]);
|
2016-02-28 13:56:18 +08:00
|
|
|
for (k = listeners.length; --k >= 0; /* empty */)
|
2014-12-20 07:04:35 +08:00
|
|
|
ee.removeListener('dummy', listeners[k]);
|
|
|
|
}
|
|
|
|
bench.end(n);
|
|
|
|
}
|