Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto.randomUUID() is slower than other runtimes #24506

Closed
ryuapp opened this issue Jul 10, 2024 · 0 comments · Fixed by #24510
Closed

crypto.randomUUID() is slower than other runtimes #24506

ryuapp opened this issue Jul 10, 2024 · 0 comments · Fixed by #24510
Assignees
Labels
ext/crypto related to the ext/crypto crate perf performance related

Comments

@ryuapp
Copy link

ryuapp commented Jul 10, 2024

crypto.randomUUID() is faster in the order Bun > Node.js > Deno.
It may be a small difference, but these may be used frequently in libraries like Request ID, and I hope it's faster.

Benchmark script:

import { bench, run } from "mitata";
let id;
bench("randomUUID", () => {
  id = crypto.randomUUID();
});

run();

Deno v1.44.4

cpu: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
runtime: deno 1.44.4 (x86_64-pc-windows-msvc)
benchmark       time (avg)             (min … max)       p75       p99      p999
-------------------------------------------------- -----------------------------
randomUUID     311 ns/iter         (0 ps … 977 ns)    977 ns    977 ns    977 ns !

Node.js v22.4.0

benchmark       time (avg)             (min … max)       p75       p99      p999
-------------------------------------------------- -----------------------------
randomUUID     198 ns/iter       (167 ns … 478 ns)    206 ns    308 ns    473 ns

Bun v1.1.18

benchmark       time (avg)             (min … max)       p75       p99      p999
-------------------------------------------------- -----------------------------
randomUUID     115 ns/iter     (82.81 ns … 509 ns)    116 ns    167 ns    239 ns
@satyarohith satyarohith added perf performance related ext/crypto related to the ext/crypto crate labels Jul 10, 2024
@satyarohith satyarohith self-assigned this Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ext/crypto related to the ext/crypto crate perf performance related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants