JSON patch supporting Map

Benchmark created on


Setup

const data = Array(10_000).map(() => crypto.randomUUID());

function isMapTarget(v) {
	return typeof v.set === 'function';
}

function isMapValue(v) {
	return v === "asdf";
}

Test runner

Ready to run.

Testing in
TestOps/sec
Support for Map
const target = {};
for (const d of data) {
	const v = isMapValue(d) ? d : d;
	if (isMapTarget(target)) {
		target.set(d, d);
	} else {
		target[d] = d;
	}
}
ready
No Support for Map
const target = {};
for (const d of data) {
	target[d] = d;
}
ready

Revisions

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