diff options
Diffstat (limited to 'bench/snippets/crypto-hasher.mjs')
-rw-r--r-- | bench/snippets/crypto-hasher.mjs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/bench/snippets/crypto-hasher.mjs b/bench/snippets/crypto-hasher.mjs new file mode 100644 index 000000000..1e850e19f --- /dev/null +++ b/bench/snippets/crypto-hasher.mjs @@ -0,0 +1,30 @@ +// so it can run in environments without node module resolution +import { bench, run } from "mitata"; + +import crypto from "node:crypto"; + +var foo = new Uint8Array(65536); +crypto.getRandomValues(foo); + +// if ("Bun" in globalThis) { +// const { CryptoHasher } = Bun; +// bench("CryptoHasher Blake2b256", () => { +// var hasher = new CryptoHasher("blake2b256"); +// hasher.update(foo); +// hasher.digest(); +// }); +// } + +bench('crypto.createHash("sha512")', () => { + var hasher = crypto.createHash("sha512"); + hasher.update(foo); + hasher.digest(); +}); + +bench('crypto.createHash("sha512")', () => { + var hasher = crypto.createHash("sha512"); + hasher.update(foo); + hasher.digest(); +}); + +await run(); |