Set.add() vs Map.values()

Benchmark created on


Setup

const set = new Set();
const map = new Map();

const values = new Array(1000).map(() => Math.random());

Test runner

Ready to run.

Testing in
TestOps/sec
Set.add()
for (const v of values) {
	set;
	map.set(`${v}`, v);
	set.add(v);
}
ready
Map.set()
for (const v of values) {
	map.values();
	map.set(`${v}`, v);
}
ready

Revisions

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