Skip to content

Commit 6d87355

Browse files
RafaelGSStargos
authored andcommitted
benchmark: add eventtarget creation bench
PR-URL: #47774 Reviewed-By: Debadree Chatterjee <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
1 parent 98450d9 commit 6d87355

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
const common = require('../common.js');
4+
const assert = require('node:assert');
5+
6+
const bench = common.createBenchmark(main, {
7+
n: [1e6],
8+
}, { flags: ['--expose-internals'] });
9+
10+
function main({ n }) {
11+
const { EventTarget } = require('internal/event_target');
12+
13+
let target;
14+
15+
bench.start();
16+
for (let i = 0; i < n; i++) {
17+
target = new EventTarget();
18+
}
19+
bench.end(n);
20+
21+
// Avoid V8 deadcode (elimination)
22+
assert.ok(target);
23+
}

0 commit comments

Comments
 (0)