Try/Catch vs null check (v4)

Revision 4 of this benchmark created on


Description

Measure performance of a try/catch block compared to a simple null check

Setup

function getTextureError() {
	throw new Error('Could not create WebGL Texture');
}

function getTextureNull() {
	return null;
}

function getTexture() {
	return {};
}

Test runner

Ready to run.

Testing in
TestOps/sec
Try/Catch
try {
	getTextureError()
} catch(e) {
}
ready
Null check
if (getTexture() === null) {
	return false
}

return true
ready

Revisions

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