Permutations

Benchmark created on


Preparation HTML

<script>
function withSlice(arr) {
	arr.reduce((a,c,i) => {
		arr.slice(i+1, arr.length)
			.forEach((item) => {
				if (c !== item) {
					a.push(`${c}-${item}`);
					a.push(`${item}-${c}`);
				}
			});
		return a;
	}, []);
}

function withoutSlice(arr) {
	arr.reduce((a,c,i) => {
		arr.forEach((item) => {
				if (c !== item) {
					a.push(`${c}-${item}`);
				}
			});
		return a;
	}, []);
}
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
with slice
withSlice(Array.from(Array(43).keys()))
ready
without slice
withoutSlice(Array.from(Array(43).keys()))
ready

Revisions

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