Add empty array benchmark
[benchmarks-js.git] / random.js
index 4b41596fd2b0ad3d1a6adaa818ec941135b48644..2f60a8c5f3c0354a6ad1f37de987824844840301 100644 (file)
--- a/random.js
+++ b/random.js
@@ -1,21 +1,14 @@
 const Benchmark = require('benchmark')
-const crypto = require('crypto')
-const { LIST_FORMATTER } = require('./benchmark-utils')
+const { LIST_FORMATTER, secureRandom } = require('./benchmark-utils')
 
 const suite = new Benchmark.Suite()
 
 const maximum = 1000
 
-/**
- *
- */
-function secureRandom () {
-  return crypto.randomBytes(4).readUInt32LE() / 0x100000000
-}
-
 /**
  * @param max
  * @param min
+ * @returns
  */
 function getSecureRandomInteger (max, min = 0) {
   max = Math.floor(max)
@@ -29,6 +22,7 @@ function getSecureRandomInteger (max, min = 0) {
 /**
  * @param max
  * @param min
+ * @returns
  */
 function getRandomInteger (max, min = 0) {
   max = Math.floor(max)
@@ -53,7 +47,7 @@ suite
     console.log(
       'Fastest is ' + LIST_FORMATTER.format(this.filter('fastest').map('name'))
     )
-    // eslint-disable-next-line no-process-exit
+    // eslint-disable-next-line n/no-process-exit
     process.exit()
   })
   .run()