perf: switch to mitata
[benchmarks-js.git] / promise-handling.mjs
index 1624bc2d18224946d95738bb0c2dac41109040bc..4c20dc2eabf5f94634eb6d4ce01e65fadad27d95 100644 (file)
@@ -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
+})