aboutsummaryrefslogtreecommitdiff
path: root/bench/snippets/crypto.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'bench/snippets/crypto.mjs')
-rw-r--r--bench/snippets/crypto.mjs18
1 files changed, 18 insertions, 0 deletions
diff --git a/bench/snippets/crypto.mjs b/bench/snippets/crypto.mjs
new file mode 100644
index 000000000..572e127bc
--- /dev/null
+++ b/bench/snippets/crypto.mjs
@@ -0,0 +1,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();