X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=inline;f=benchmark-utils.js;h=e39708b7cf3cfe1cf18b92e25bd1994567f01e26;hb=a0e41b9ef100648a3a5023b1e419b48bb39eeabe;hp=83d17ca7a7c4bb461d21dc4c994bc4e53b380ee4;hpb=8e1fbc065cb9d9027c8fad951ff1a0d9960dbce5;p=benchmarks-js.git diff --git a/benchmark-utils.js b/benchmark-utils.js index 83d17ca..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 @@ -95,5 +104,6 @@ module.exports = { generateRandomNumberArray, generateRandomObject, sleep, - secureRandom + secureRandom, + secureRandomWithRandomValues }