Testing mark and mesure performance impact

Benchmark created on


Setup

const names = new Array(100000).fill("0").map((_, index) => `datNameTho${index}`);

let enabled = false;
function safeMark(...args) {
	if (enabled) {
		performance.mark(...args);
	}
}

function safeMeasure(...args) {
	if (enabled) {
		performance.measure(...args);
	}
}

Test runner

Ready to run.

Testing in
TestOps/sec
Without mark and measure
names.forEach((val, index) => {
	const manipulateIt = val.at(0);
});
ready
With mark and measure
names.forEach((val, index) => {
	performance.mark("start");
	const manipulateIt = val.at(0);
	performance.measure("end", "start");
});
ready
With optional mark and measure disabled
names.forEach((val, index) => {
	safeMark("start");
	const manipulateIt = val.at(0);
	safeMeasure("end", "start");
});
ready

Revisions

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