Skip to content

Commit

Permalink
benchmark: add eventtarget creation bench
Browse files Browse the repository at this point in the history
PR-URL: #47774
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
  • Loading branch information
RafaelGSS authored and MoLow committed Jul 6, 2023
1 parent fd0f362 commit 60ca69d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions benchmark/events/eventtarget-creation.js
@@ -0,0 +1,23 @@
'use strict';

const common = require('../common.js');
const assert = require('node:assert');

const bench = common.createBenchmark(main, {
n: [1e6],
}, { flags: ['--expose-internals'] });

function main({ n }) {
const { EventTarget } = require('internal/event_target');

let target;

bench.start();
for (let i = 0; i < n; i++) {
target = new EventTarget();
}
bench.end(n);

// Avoid V8 deadcode (elimination)
assert.ok(target);
}

0 comments on commit 60ca69d

Please sign in to comment.