X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmark-utils.mjs;h=59521b614ebee8564dd93e258bac032bba210ddb;hb=748f5a35ac3fcca82294802613cd638d0e9ac935;hp=202a9a08ac4eb42f79f975e23b0f00f03fc1d9e7;hpb=48f5216deed3bc4d9a64e81822fe8d6bd5c5cdcd;p=benchmarks-js.git diff --git a/benchmark-utils.mjs b/benchmark-utils.mjs index 202a9a0..59521b6 100644 --- a/benchmark-utils.mjs +++ b/benchmark-utils.mjs @@ -1,4 +1,4 @@ -import crypto from 'crypto' +import crypto, { webcrypto } from 'node:crypto' /** * Generate a cryptographically secure random number in the [0,1[ range @@ -9,11 +9,11 @@ export function secureRandom () { } /** - * Generate a cryptographically secure random number in the [0,1[ range + * Generate a cryptographically secure random number in the [0,1[ range * @returns */ export function secureRandomWithRandomValues () { - return crypto.getRandomValues(new Uint32Array(1))[0] / 0x100000000 + return webcrypto.getRandomValues(new Uint32Array(1))[0] / 0x100000000 } /** @@ -93,5 +93,5 @@ export function generateRandomObject ( * @returns */ export async function sleep (ms) { - return new Promise((resolve) => setTimeout(resolve, ms)) + return await new Promise(resolve => setTimeout(resolve, ms)) }