build(deps-dev): apply updates
[benchmarks-js.git] / promise-handling.mjs
index ffb42ff96861de27332160a9748cbecf1e8755da..0d3f88fb30e554189b55b9668a550df0caccab13 100644 (file)
@@ -1,63 +1,38 @@
-import Benchmark from 'benny'
+import { bench, group, run } from 'tatami-ng'
 
 /**
  *
  */
-function promise () {
-  return new Promise((resolve) => {
+async function asyncFunction () {
+  await new Promise(resolve => {
     resolve()
   })
 }
 
-/**
- *
- */
-async function asyncFunction () {
-  return await promise()
-}
-
-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) => {
+      .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
 })