summaryrefslogtreecommitdiff
path: root/benchmark/util/priority-queue.js
blob: 9cff7cbbacba84f6d0bbc574735419e81415580a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
'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 (var i = 0; i < n; i++)
    queue.insert(Math.random() * 1e7 | 0);
  for (i = 0; i < n; i++)
    queue.shift();
  bench.end(n);
}