arr compare

Benchmark created on


Setup

const baseGroups = [
    "3A/8/R",
    "3B/8/R",
    "3C/8/R",
    "3D/8/R"
]

const newGroups = [
    "3A/8/R",
    "3B/8/Rs",
    "3C/8/R",
    "3D/8/R",
]

const areGroupsEqual = (baseG, newG) => {
	return baseG.toSorted().join(",") === newG.toSorted().join(",")
}

const areGroupsEqual2 = (baseGroups, newGroups) => {
	if (baseGroups.length !== newGroups.length) return false

	const baseGroupsSorted = baseGroups.toSorted()
	const newGroupsSorted = newGroups.toSorted()
	
	return baseGroupsSorted.every((val, i) => val === newGroupsSorted[i])
}

Test runner

Ready to run.

Testing in
TestOps/sec
string join
areGroupsEqual(baseGroups, newGroups)
ready
iteration
areGroupsEqual2(baseGroups, newGroups)
ready

Revisions

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