X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=promise-handling.mjs;h=5ace30e862052584859f7cd028b334beaada6ed5;hb=cb91ac61b626d885d16c0d1728f36837f67d7dc5;hp=7f450b3fc53c58f3e93abd821b6490ba7519d260;hpb=bcd364e02f04150362bd573ff124c1c6426b7718;p=benchmarks-js.git diff --git a/promise-handling.mjs b/promise-handling.mjs index 7f450b3..5ace30e 100644 --- a/promise-handling.mjs +++ b/promise-handling.mjs @@ -1,4 +1,4 @@ -import Benchmark from 'benny' +import { bench, group, run } from 'tatami-ng' /** * @@ -9,48 +9,30 @@ async function asyncFunction () { }) } -Benchmark.suite( - 'Promise handling', - Benchmark.add('await promise', async () => { +group('Promise handling', () => { + bench('await promise', async () => { try { return await asyncFunction() } catch (e) { console.error(e) } - }), - Benchmark.add('promise with then().catch()', () => { + }) + bench('promise with then().catch()', () => { asyncFunction() .then(r => { return r }) - .catch(e => { - console.error(e) - }) - }), - Benchmark.add('voided promise', () => { + .catch(console.error) + }) + bench('voided promise', () => { // eslint-disable-next-line no-void void asyncFunction() - }), - Benchmark.add('mishandled promise', () => { + }) + bench('mishandled promise', () => { asyncFunction() - }), - Benchmark.cycle(), - Benchmark.complete(), - Benchmark.save({ - file: 'promise-handling', - format: 'json', - details: true - }), - Benchmark.save({ - file: 'promise-handling', - format: 'chart.html', - details: true - }), - Benchmark.save({ - file: 'promise-handling', - format: 'table.html', - details: true }) -).catch(err => { - console.error(err) +}) + +await run({ + units: true, })