Set vs Map

Benchmark created on


Preparation HTML

	

Setup

const data =
	Array(16384)
		.fill(0)
		.map((_, i) => i % 128);

const data_sorted =
	data.slice()
		.sort();

Test runner

Ready to run.

Testing in
TestOps/sec
Map
const xy = new Map();

data.forEach(v => xy.set(v, true));

const unique_items = Array.from(xy.keys());
ready
Set
const sxy = new Set();

data.forEach(v => sxy.add(v));

const unique_items = Array.from(sxy.values());
ready

Revisions

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