node/benchmark/crypto/randomUUID.js
James M Snell 0008a675ff crypto: implement randomuuid
Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/36729
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Ben Coe <bencoe@gmail.com>
2021-01-07 12:44:36 -08:00

18 lines
388 B
JavaScript

'use strict';
const common = require('../common.js');
const { randomUUID } = require('crypto');
const bench = common.createBenchmark(main, {
n: [1e7],
disableEntropyCache: [0, 1],
});
function main({ n, disableEntropyCache }) {
disableEntropyCache = !!disableEntropyCache;
bench.start();
for (let i = 0; i < n; ++i)
randomUUID({ disableEntropyCache });
bench.end(n);
}