Try-catch vs conditions

Benchmark created by tswistak on


Setup

var obj = {};

Test runner

Ready to run.

Testing in
TestOps/sec
Try-Catch
try {
    obj.doIt();
} catch(e) {
    // do nothing
}
ready
If condition
if (obj.doIt) {
    obj.doIt();
}
ready
Short-circuit evaluation
obj.doIt && obj.doIt();
ready

Revisions

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