Try/Catch Error Perf (v65)

Revision 65 of this benchmark created by Daniel on


Preparation HTML

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

  function tryCatchError(undef) {
    try {
      return undef.prop;
    } catch (ex) {
      return new Error();
    }
  }

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

  function ifCheckError(undef) {
    if (undef !== undefined) {
      return undef.prop;
    } else {
      return new Error();
    }
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Try Catch
tryCatch();
ready
Try Catch returns Error
tryCatchError();
ready
TryCatch No Error
tryCatch({
  prop: 0
});
ready
If Check
ifCheck();
ready
If Check returns Error
ifCheckError();
ready
If Check No Error
ifCheck({
  prop: 0
});
ready

Revisions

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