Unique id

Benchmark created on


Setup

let count = 0

let a="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let nanoid=(e=6)=>{let t="",r=crypto.getRandomValues(new Uint8Array(e));for(let n=0;n<e;n++)t+=a[63&r[n]];return t};

Test runner

Ready to run.

Testing in
TestOps/sec
crypto.randomUUID()
return crypto.randomUUID()
ready
Math.random()
return String(Math.random())
ready
Counter
return String(++count)
ready
Nanoid-browser-prebuilt (length=6)
return nanoid()
ready
Math.random() to 11 characters
return Math.random().toString().substring(2, 11)
ready
nordcraft nanoid approximation (length=6)
return Array
	.from({ length: 6 }, () => 0)
	.map(x => a[Math.round(Math.random() * 64 - 0.5)])
	.join()
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.