X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmark-utils.js;h=e39708b7cf3cfe1cf18b92e25bd1994567f01e26;hb=9db6379f83a78902f85f14d7cc672e8bdb7b4968;hp=9c82d8438c1df329ceed3a4317ba2db9a3f0370f;hpb=5b907dbf7ed955584eb9f452f9dc4c8f59577816;p=benchmarks-js.git diff --git a/benchmark-utils.js b/benchmark-utils.js index 9c82d84..e39708b 100644 --- a/benchmark-utils.js +++ b/benchmark-utils.js @@ -9,6 +9,15 @@ function secureRandom () { return crypto.randomBytes(4).readUInt32LE() / 0x100000000 } +/** + * Generate a cryptographically secure random number in the [0,1[ range + * + * @returns + */ +function secureRandomWithRandomValues () { + return crypto.getRandomValues(new Uint32Array(1))[0] / 0x100000000 +} + /** * @param max * @param min @@ -78,7 +87,7 @@ function generateRandomObject ( for (let i = 0; i < size; i++) { object[i.toString()] = numberGenerator(numberMax) } - return { object, size } + return object } /** @@ -95,5 +104,6 @@ module.exports = { generateRandomNumberArray, generateRandomObject, sleep, - secureRandom + secureRandom, + secureRandomWithRandomValues }