Comparing sets equality

Benchmark created on


Setup

const arrayOfItems = new Array(100_000);

function randomizeArrayIds(array) {
    for (var i = array.length - 1; i > 0; i--) {
		array[i] = { id: Math.floor(Math.random() * 10_000) };
    }
}

randomizeArrayIds(arrayOfItems);
const a = new Set(arrayOfItems);
const b = new Set(arrayOfItems);

Test runner

Ready to run.

Testing in
TestOps/sec
a.size == b.size && a.size == a.union(b).size
a.size == b.size && a.size == a.union(b).size
ready
a.isSupersetOf(b) && a.isSubsetOf(b)
a.isSupersetOf(b) && a.isSubsetOf(b)
ready
a.symmetricDifference(b).size == 0
a.symmetricDifference(b).size == 0
ready
a.size === b.size && a.isSubsetOf(b)
a.size === b.size && a.isSubsetOf(b)
ready

Revisions

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