X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=random.mjs;h=70d48c0a53fbf6084db9481a12e9dee865fb969e;hb=3d3820c6d32315be92b08f19b905b352dad8506d;hp=e1062c05c7e4a4d17749645af4d8a271ac0fd547;hpb=f913c68ce1ad111704f1f319706cb99e9659e236;p=benchmarks-js.git diff --git a/random.mjs b/random.mjs index e1062c0..70d48c0 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)