Skip to content

Commit

Permalink
[fixup] more flexible emit benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
apapirovski committed Nov 8, 2017
1 parent b659275 commit 8b95f82
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 43 deletions.
20 changes: 0 additions & 20 deletions benchmark/events/ee-emit-2-args.js

This file was deleted.

20 changes: 0 additions & 20 deletions benchmark/events/ee-emit-4-args.js

This file was deleted.

16 changes: 13 additions & 3 deletions benchmark/events/ee-emit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,29 @@
const common = require('../common.js');
const EventEmitter = require('events').EventEmitter;

const bench = common.createBenchmark(main, { n: [2e6] });
const bench = common.createBenchmark(main, {
n: [2e6],
argc: [0, 2, 4, 10],
listeners: [1, 5, 10],
});

function main(conf) {
const n = conf.n | 0;
const argc = conf.argc | 0;
const listeners = conf.listeners | 0;

const ee = new EventEmitter();

for (var k = 0; k < 10; k += 1)
const args = new Array(argc);
args.fill(10);
args.unshift('dummy');

for (var k = 0; k < listeners; k += 1)
ee.on('dummy', function() {});

bench.start();
for (var i = 0; i < n; i += 1) {
ee.emit('dummy');
ee.emit.apply(ee, args);
}
bench.end(n);
}

0 comments on commit 8b95f82

Please sign in to comment.