X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=random.mjs;h=16037df91dff6aaaa47880b1247be00525161878;hb=84b763a298a88a7e9aa581210108cd57c8e2000b;hp=d59c81359809a995111ba10bab27ef4874a8bd8b;hpb=48f5216deed3bc4d9a64e81822fe8d6bd5c5cdcd;p=benchmarks-js.git diff --git a/random.mjs b/random.mjs index d59c813..16037df 100644 --- a/random.mjs +++ b/random.mjs @@ -1,4 +1,4 @@ -import crypto from 'crypto' +import { randomInt } from 'node:crypto' import Benchmark from 'benny' import { secureRandom, @@ -76,9 +76,9 @@ Benchmark.suite( max = Math.floor(max) if (min != null && min !== 0) { min = Math.ceil(min) - return Math.floor(crypto.randomInt(min, max + 1)) + return Math.floor(randomInt(min, max + 1)) } - return Math.floor(crypto.randomInt(max + 1)) + return Math.floor(randomInt(max + 1)) }), Benchmark.add('Math random integer generator', () => { getRandomInteger(maximum) @@ -100,6 +100,4 @@ Benchmark.suite( format: 'table.html', details: true }) -).catch((err) => { - console.error(err) -}) +).catch(console.error)