blob: 2f96dae7b6b0a52b095c001da69f26c0f82a818a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// so it can run in environments without node module resolution
import { bench, run } from "./runner.mjs";
import crypto from "node:crypto";
var foo = Buffer.allocUnsafe(16384);
foo.fill(123);
// 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("sha256")', () => {
var hasher = crypto.createHash("sha256");
hasher.update(foo);
hasher.digest();
});
bench('crypto.createHash("sha1")', () => {
var hasher = crypto.createHash("sha1");
hasher.update(foo);
hasher.digest();
});
await run();
|