X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=promise-handling.js;h=4e83dc54268f278c6d5de9d2dd29b96cf873a4d3;hb=a879df19626f876239fe292edfaab5827644065e;hp=b07b33d835583ae15f6edf8fd26b6cbc437953eb;hpb=ce26b710fea3b0e48d26fc7565f393cb211b585e;p=benchmarks-js.git diff --git a/promise-handling.js b/promise-handling.js index b07b33d..4e83dc5 100644 --- a/promise-handling.js +++ b/promise-handling.js @@ -19,9 +19,26 @@ async function asyncFunction () { Benchmark.suite( 'Promise handling', Benchmark.add('await promise', async () => { - await asyncFunction() + try { + return await asyncFunction() + } catch (e) { + console.error(e) + } }), - Benchmark.add('promise', () => { + Benchmark.add('promise with then().catch()', () => { + asyncFunction() + .then(r => { + return r + }) + .catch(e => { + console.error(e) + }) + }), + Benchmark.add('voided promise', () => { + // eslint-disable-next-line no-void + void asyncFunction() + }), + Benchmark.add('mishandled promise', () => { asyncFunction() }), Benchmark.cycle(),