Set vs Map (v3)

Revision 3 of this benchmark created on


Preparation HTML

	

Setup

const data_128 =
	Array(2 ** 14)
		.fill(0)
		.map((_, i) => i % 2 ** 7);
		
const data_4096 =
	Array(2 ** 14)
		.fill(0)
		.map((_, i) => i % 2 ** 12);

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

Test runner

Ready to run.

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

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

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

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

const unique_items = Array.from(sxy.values());
ready
Map 4096
const xy = new Map();

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

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

data_4096.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.