DEV Community

Discussion on: crypto.randomUUID is three times faster uuid.v4

Collapse
 
jdgamble555 profile image
Jonathan Gamble

This package is depreciated. Use uuid instead.

npm i uuid
npm i -D @types/uuid
Enter fullscreen mode Exit fullscreen mode
import { v4 } from 'uuid';

v4();
Enter fullscreen mode Exit fullscreen mode

J

Collapse
 
ehaynes99 profile image
Eric Haynes • Edited

I didn't get all fancy with hyperfine, but a cursory test shows no appreciable difference in performance with npmjs.com/package/uuid. Still, 2 less dependencies is nice. :)

uuid.v4 took 954.153 ms
randomUUID took 962.838 ms
uuid.v4 took 987.495 ms
randomUUID took 965.426 ms
uuid.v4 took 984.862 ms
randomUUID took 949.582 ms
Enter fullscreen mode Exit fullscreen mode