aboutsummaryrefslogtreecommitdiff
path: root/bench/snippets/crypto.mjs
blob: 572e127bcd610308f8036ad2252573afdcaae66a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// so it can run in environments without node module resolution
import { bench, run } from "../node_modules/mitata/src/cli.mjs";

// web crypto is not a global in node
if (!globalThis.crypto) {
  globalThis.crypto = await import("crypto");
}

var foo = new Uint8Array(2);
bench("crypto.getRandomValues()", () => {
  crypto.getRandomValues(foo);
});

bench("crypto.randomUUID()", () => {
  crypto.randomUUID();
});

await run();