Set constructor vs set.add (v3)

Revision 3 of this benchmark created on


Setup

const a = [];

for (i = 0; i <= 1_000_000; i++) {
	a[i] = i;
}

Test runner

Ready to run.

Testing in
TestOps/sec
Set constructor
const s = new Set(a);


ready
Set.add
const s = new Set();

for (const i of a) {
	s.add(i)
}
ready

Revisions

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