0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-22 07:37:56 +01:00
nodejs/benchmark/util/priority-queue.js
Antoine du Hamel 83cc1e2c8b
benchmark: add trailing commas in benchmark/util
PR-URL: https://github.com/nodejs/node/pull/46438
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: James M Snell <jasnell@gmail.com>
2023-02-03 11:42:25 +01:00

19 lines
433 B
JavaScript

'use strict';
const common = require('../common');
const bench = common.createBenchmark(main, {
n: [1e5],
}, { flags: ['--expose-internals'] });
function main({ n, type }) {
const PriorityQueue = require('internal/priority_queue');
const queue = new PriorityQueue();
bench.start();
for (let i = 0; i < n; i++)
queue.insert(Math.random() * 1e7 | 0);
for (let i = 0; i < n; i++)
queue.shift();
bench.end(n);
}