X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=promise-handling.mjs;h=4c20dc2eabf5f94634eb6d4ce01e65fadad27d95;hb=ab9a08f3b8fdd43f8714e90652028621849f9f58;hp=1624bc2d18224946d95738bb0c2dac41109040bc;hpb=1b4e2f913afc4f5dfed823720d89dde05d23d184;p=benchmarks-js.git diff --git a/promise-handling.mjs b/promise-handling.mjs index 1624bc2..4c20dc2 100644 --- a/promise-handling.mjs +++ b/promise-handling.mjs @@ -1,4 +1,4 @@ -import Benchmark from 'benny' +import { bench, group, run } from 'mitata' /** * @@ -9,44 +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(console.error) - }), - Benchmark.add('voided promise', () => { + }) + 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(console.error) +}) + +await run({ + units: true +})