try/catch .try.catch

Benchmark created on


Setup

async function fsStat() {
  if (Math.random() >= 0.5) {
    throw "AAAAAAA";
  } else {
    return {};
  }
}

async function test1() {
  try {
    await fsStat();
    return true;
  } catch (_error) {
    return false;
  }
}

async function test2() {
  return fsStat().then(() => true).catch(() => false)
}

Test runner

Ready to run.

Testing in
TestOps/sec
try/catch
await test1()
ready
.try.catch
await test2()
ready

Revisions

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