Throwing vs Branching (v3)

Revision 3 of this benchmark created on


Description

A demonstration of how good try-catch performs vs traditional branching, also known as object creation skewing performance test results.

Test runner

Ready to run.

Testing in
TestOps/sec
Throwing
const x = false;
try {
	if (!x) throw x;
	console.log('x is true');
} catch {
	console.log('x is false')
}
ready
Not Throwing
const x = false;
if (!x) {
	console.log('x is false');
} else {
	console.log('x is true');
}
ready
try-catch without throwing
const x = true;
try {
	if (!x) throw x;
	console.log('x is true');
} catch {
	console.log('x is false')
}
ready
x is true
const x = true;
if (!x) {
	console.log('x is false');
} else {
	console.log('x is true');
}
ready

Revisions

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