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 targos committed May 3, 2023
1 parent 98450d9 commit 6d87355
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions benchmark/events/eventtarget-creation.js
Original file line number Diff line number Diff line change
@@ -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 6d87355

Please sign in to comment.