X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=random.js;h=8c0fa86e669b384e4d812478e00b6a61716031c8;hb=0727a8661f710c5330f02fed6c739fc79ea19b22;hp=272d8e6969c23f71c234cad66ca93d8ffbe889dd;hpb=823ca29667e5d5e4951f629ebe19ae8ec1f44b52;p=benchmarks-js.git diff --git a/random.js b/random.js index 272d8e6..8c0fa86 100644 --- a/random.js +++ b/random.js @@ -1,9 +1,9 @@ +const crypto = require('crypto') const Benchmark = require('benny') const { secureRandom, secureRandomWithRandomValues } = require('./benchmark-utils') -const crypto = require('crypto') const maximum = 281474976710654 @@ -74,7 +74,7 @@ Benchmark.suite( ), Benchmark.add('Crypto random integer generator', (max = maximum, min = 0) => { max = Math.floor(max) - if (min !== undefined && min !== 0) { + if (min != null && min !== 0) { min = Math.ceil(min) return Math.floor(crypto.randomInt(min, max + 1)) } @@ -100,4 +100,6 @@ Benchmark.suite( format: 'table.html', details: true }) -) +).catch(err => { + console.error(err) +})