From d83e9faf2cd5dc53fcc15cedf25fd86719088ec7 Mon Sep 17 00:00:00 2001 From: RafaelGSS Date: Wed, 30 Oct 2024 22:58:06 -0300 Subject: [PATCH] benchmark: add nodeTiming.uvmetricsinfo bench MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/55614 Reviewed-By: Juan José Arboleda Reviewed-By: Matteo Collina Reviewed-By: Stephen Belanger Reviewed-By: Vinícius Lourenço Claro Cardoso --- .../perf_hooks/nodetiming-uvmetricsinfo.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 benchmark/perf_hooks/nodetiming-uvmetricsinfo.js diff --git a/benchmark/perf_hooks/nodetiming-uvmetricsinfo.js b/benchmark/perf_hooks/nodetiming-uvmetricsinfo.js new file mode 100644 index 00000000000..1d8d174de14 --- /dev/null +++ b/benchmark/perf_hooks/nodetiming-uvmetricsinfo.js @@ -0,0 +1,29 @@ +'use strict'; + +const common = require('../common.js'); +const assert = require('node:assert'); +const fs = require('node:fs/promises'); + +const { + performance, +} = require('perf_hooks'); + +const bench = common.createBenchmark(main, { + n: [1e6], + events: [1, 1000, 10000], +}); + +async function runEvents(events) { + for (let i = 0; i < events; ++i) { + assert.ok(await fs.statfs(__filename)); + } +} + +async function main({ n, events }) { + await runEvents(events); + bench.start(); + for (let i = 0; i < n; i++) { + assert.ok(performance.nodeTiming.uvMetricsInfo); + } + bench.end(n); +}