X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=random.js;h=2f60a8c5f3c0354a6ad1f37de987824844840301;hb=2deff321e347e2ca6c419c5d98b82fe2f5595a03;hp=4b41596fd2b0ad3d1a6adaa818ec941135b48644;hpb=aa697b2fb25ad4f2504dfc2a67ecd03d4e58fc77;p=benchmarks-js.git diff --git a/random.js b/random.js index 4b41596..2f60a8c 100644 --- 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()