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 <shishugi@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
Brian White 2020-06-21 11:54:24 -04:00 committed by James M Snell
parent 4629e96c20
commit 336546b075
No known key found for this signature in database
GPG Key ID: 7341B15C070877AC

View File

@ -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);