From 8b95f8256137b60b19c845b7f63b9382a107a4ae Mon Sep 17 00:00:00 2001 From: Anatoli Papirovski Date: Wed, 8 Nov 2017 12:39:07 -0500 Subject: [PATCH] [fixup] more flexible emit benchmark --- benchmark/events/ee-emit-2-args.js | 20 -------------------- benchmark/events/ee-emit-4-args.js | 20 -------------------- benchmark/events/ee-emit.js | 16 +++++++++++++--- 3 files changed, 13 insertions(+), 43 deletions(-) delete mode 100644 benchmark/events/ee-emit-2-args.js delete mode 100644 benchmark/events/ee-emit-4-args.js diff --git a/benchmark/events/ee-emit-2-args.js b/benchmark/events/ee-emit-2-args.js deleted file mode 100644 index ffe6c16a402f07..00000000000000 --- a/benchmark/events/ee-emit-2-args.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const EventEmitter = require('events').EventEmitter; - -const bench = common.createBenchmark(main, { n: [2e6] }); - -function main(conf) { - const n = conf.n | 0; - - const ee = new EventEmitter(); - - 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', 5, true); - } - bench.end(n); -} diff --git a/benchmark/events/ee-emit-4-args.js b/benchmark/events/ee-emit-4-args.js deleted file mode 100644 index bf13100a68f6be..00000000000000 --- a/benchmark/events/ee-emit-4-args.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const EventEmitter = require('events').EventEmitter; - -const bench = common.createBenchmark(main, { n: [2e6] }); - -function main(conf) { - const n = conf.n | 0; - - const ee = new EventEmitter(); - - 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', 5, true, 'something', false); - } - bench.end(n); -} diff --git a/benchmark/events/ee-emit.js b/benchmark/events/ee-emit.js index 9eef9f675605e2..01f5d4ac3b95a5 100644 --- a/benchmark/events/ee-emit.js +++ b/benchmark/events/ee-emit.js @@ -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); }