From 8586be21a012685e2897aa798186d9c65dbc0ce6 Mon Sep 17 00:00:00 2001 From: RafaelGSS Date: Fri, 28 Apr 2023 17:47:11 -0300 Subject: [PATCH] benchmark: add eventtarget creation bench --- benchmark/events/eventtarget-creation.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 benchmark/events/eventtarget-creation.js diff --git a/benchmark/events/eventtarget-creation.js b/benchmark/events/eventtarget-creation.js new file mode 100644 index 00000000000000..faf04978d6526b --- /dev/null +++ b/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); +}