ai / nanoid

A tiny (124 bytes), secure, URL-friendly, unique string ID generator for JavaScript
https://zelark.github.io/nano-id-cc/
MIT License
24.34k stars 789 forks source link

What about benchmarks? #494

Closed MrOxMasTer closed 2 weeks ago

MrOxMasTer commented 2 weeks ago

Why does nanoid lose out in terms of the number of operations per second to uuid? image

Before that, it was the opposite: image

And a question. Have there been any comparisons and benchmarks in postgresql using nanoid and 128-bit UUID. I just don't understand if it makes sense for me to use this library other than short id?

ai commented 2 weeks ago

Why does nanoid lose out in terms of the number of operations per second to uuid?

Because uuid uses built-in UUID generator from Node.js, which is more memory efficient because it was written on C.

I just don't understand if it makes sense for me to use this library other than short id?

Nano ID has 2 reasons to use it over uuid:

  1. Smaller JS bundle for browser.
  2. Shorter IDs, which could be important if they are visible for users.