Skip to content

Commit 60ca69d

Browse files
RafaelGSSMoLow
authored andcommitted
benchmark: add eventtarget creation bench
PR-URL: #47774 Reviewed-By: Debadree Chatterjee <debadree333@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent fd0f362 commit 60ca69d

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)