Skip to content

trevorwhealy/uuid-comparison

Folders and files

NameName
Last commit message
Last commit date

Latest commit

1d1e570 · Sep 25, 2023

History

1 Commit
Sep 25, 2023
Sep 25, 2023
Sep 25, 2023
Sep 25, 2023
Sep 25, 2023
Sep 25, 2023
Sep 25, 2023
Sep 25, 2023
Sep 25, 2023

Repository files navigation

What?

Comparing the performance of native Node.js crypto utility vs libraries NanoID and UUID (v4).

Why?

We may reach for certain libraries because "everyone uses it" without asking what is the tradeoff?

How?

Created three scripts that all work the same: import the utility and then run it 10 million times.

const { utility } = await import('...');

for (let i = 0; i < 10000000; i++) {
    utility();
}

Then I used hyperfine to run each script at least 10 times and take the average.

hyperfine 'node uuid.js' 'node crypto.js' 'node nanoid.js' --warmup 3 --min-runs 10

Specs

Computer: MacBook Pro (16-inch, 2021) OS: macOS Ventura 13.4.1 Chip: Apple M1 Pro RAM: 16 GB

Result

Result

Demo

Demo

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published