mirror of
https://github.com/nodejs/node.git
synced 2024-11-29 15:06:33 +01:00
0011eb28cf
Currently most of the event tests only test a single event type, which might let those benchmark take fast-paths (in V8) that aren't taken in realistic use cases, and thus the benchmarks are not good proxies of real world uses. PR-URL: https://github.com/nodejs/node/pull/14052 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
22 lines
439 B
JavaScript
22 lines
439 B
JavaScript
'use strict';
|
|
var common = require('../common.js');
|
|
var EventEmitter = require('events').EventEmitter;
|
|
|
|
var bench = common.createBenchmark(main, {n: [2e7]});
|
|
|
|
function main(conf) {
|
|
var n = conf.n | 0;
|
|
|
|
var ee = new EventEmitter();
|
|
|
|
function listener() {}
|
|
|
|
bench.start();
|
|
for (var i = 0; i < n; i += 1) {
|
|
var dummy = (i % 2 === 0) ? 'dummy0' : 'dummy1';
|
|
ee.once(dummy, listener);
|
|
ee.emit(dummy);
|
|
}
|
|
bench.end(n);
|
|
}
|