Get a key for a list of primitives

Benchmark created on


Setup

const list = [];
for (let i = 0; i < 10000; i++) {
	if (Math.random() < 0.3) list.push(Math.random());
	if (Math.random() < 0.3)
	  list.push(String(Math.random()));
	if (Math.random() < 0.05) list.push(true);
}

Test runner

Ready to run.

Testing in
TestOps/sec
JSON stringify
JSON.stringify(list);
ready
Manual stringification
list.map((item) => typeof item + String(item)).join(",");
ready

Revisions

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