Overhead of a function

Benchmark created on


Setup

const items = [new Array(), new Error(), new Array(), new Error()];
function test(o) {
	if (o instanceof Array) {
		return true;
	}
	if (o instanceof Error) {
		return true;
	}
	return false;
}

Test runner

Ready to run.

Testing in
TestOps/sec
function
for (let item of items) {
	item = test(item);
}
ready
instanceof
for (let item of items) {
	if (item instanceof Array) {
		item = true;
	} else if (item instanceof Error) {
		item = true;
	} else {
		item = false;
	}
}
ready

Revisions

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