From 0eed22d6ed6335fef2e848391860ddde2f1e41cb Mon Sep 17 00:00:00 2001 From: Brian White Date: Sun, 21 Jun 2020 11:54:24 -0400 Subject: [PATCH] benchmark: fix EventTarget benchmark Fixes: https://github.com/nodejs/node/issues/33782 PR-URL: https://github.com/nodejs/node/pull/34015 Reviewed-By: Denys Otrishko Reviewed-By: Benjamin Gruenbaum --- benchmark/events/eventtarget.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/benchmark/events/eventtarget.js b/benchmark/events/eventtarget.js index 7a7253aefb1347..d2c3ad034ff9b4 100644 --- a/benchmark/events/eventtarget.js +++ b/benchmark/events/eventtarget.js @@ -2,7 +2,7 @@ const common = require('../common.js'); const bench = common.createBenchmark(main, { - n: [2e7], + n: [1e6], listeners: [1, 5, 10] }, { flags: ['--expose-internals'] }); @@ -13,11 +13,9 @@ function main({ n, listeners }) { for (let n = 0; n < listeners; n++) target.addEventListener('foo', () => {}); - const event = new Event('foo'); - bench.start(); for (let i = 0; i < n; i++) { - target.dispatchEvent(event); + target.dispatchEvent(new Event('foo')); } bench.end(n);