Try/Catch Error Perf (v48)

Revision 48 of this benchmark created by bam on


Preparation HTML

<script>
  function tryCatch(undef) {
    try {
      return undef.prop;
    } catch (ex) {
      return null;
    }
  }

  function ifCheck(undef) {
    if (undef !== undefined) {
      return undef.prop;
    } else {
      return null;
    }
  }

  function ifTypeCheck(undef) {
    if (typeof(undef) !== 'undefined') {
      return undef.prop;
    } else {
      return null;
    }
  }

  function autoVivi(undef) {
    return (undef || {}).prop
  }

  var zombieVivi = (function() {
    var def = {prop:null};
    return function(undef) {
      return (undef || def).prop;
    };
  })();

  function shx(a){return (a!==undefined)?a.prop:null};

  function sh(a){ return a ? a.prop : null; };
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Try Catch
tryCatch(Object);
tryCatch();
ready
If Check
ifCheck(Object);
ifCheck();
ready
If type Check
ifTypeCheck(Object);
ifTypeCheck();
ready
autovivifivcation
autoVivi(Object)
autoVivi()
ready
shx
shx(Object)
shx()
ready
zombieVivi
zombieVivi(Object);
zombieVivi();
ready
sh
sh(Object);
sh();
ready

Revisions

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