Add crypto API randomInt() to random benchmarks
[benchmarks-js.git] / benchmark-utils.js
index 83d17ca7a7c4bb461d21dc4c994bc4e53b380ee4..121ef4ad375b6af43d43924677b070f88c024843 100644 (file)
@@ -9,6 +9,15 @@ function secureRandom () {
   return crypto.randomBytes(4).readUInt32LE() / 0x100000000
 }
 
+/**
+ *  Generate a cryptographically secure random number in the [0,1[ range
+ *
+ * @param
+ */
+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
 }