-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
events: initial implementation of experimental EventTarget
See documentation changes for details Signed-off-by: James M Snell <[email protected]> PR-URL: #33556 Refs: #33527 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Bradley Farias <[email protected]>
- Loading branch information
1 parent
20d54f6
commit 1c70b18
Showing
8 changed files
with
1,316 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
const common = require('../common.js'); | ||
|
||
const bench = common.createBenchmark(main, { | ||
n: [2e7], | ||
listeners: [1, 5, 10] | ||
}, { flags: ['--expose-internals'] }); | ||
|
||
function main({ n, listeners }) { | ||
const { EventTarget, Event } = require('internal/event_target'); | ||
const target = new EventTarget(); | ||
|
||
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); | ||
} | ||
bench.end(n); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.