X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=promise-handling.mjs;h=0d3f88fb30e554189b55b9668a550df0caccab13;hb=c7d6615d759b56dc3ba10dcfadd51854929b2d30;hp=1624bc2d18224946d95738bb0c2dac41109040bc;hpb=4aa2893a787119ef9b3957e82539fee4fad4f98f;p=benchmarks-js.git diff --git a/promise-handling.mjs b/promise-handling.mjs index 1624bc2..0d3f88f 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,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 +})