Try/Catch Error Perf (v47)

Revision 47 of this benchmark created 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
  }

  function shx(a){return (a!==undefined)?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

Revisions

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