Run if exists or run empty

Benchmark created by Anderberg on


Description

Is checking if a function exists before running it faster than simply running an empty function?

Setup

function Omg () {}
    Omg.prototype.empty = function () {};
    
    var o = new Omg();

Test runner

Ready to run.

Testing in
TestOps/sec
If function
if (o.empty2) { // Does not exist
    o.empty2();
}
ready
Empty function
o.empty();
ready

Revisions

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

  • Revision 1: published by Anderberg on