Apply dependencies update
[benchmarks-js.git] / promise-handling.js
index 002be6d429392264772e61aff6f617bebee0c277..4e83dc54268f278c6d5de9d2dd29b96cf873a4d3 100644 (file)
@@ -13,15 +13,32 @@ function promise () {
  *
  */
 async function asyncFunction () {
-  await promise()
+  return await promise()
 }
 
 Benchmark.suite(
   'Promise handling',
   Benchmark.add('await promise', async () => {
-    await asyncFunction()
+    try {
+      return await asyncFunction()
+    } catch (e) {
+      console.error(e)
+    }
   }),
-  Benchmark.add('promise', () => {
+  Benchmark.add('promise with then().catch()', () => {
+    asyncFunction()
+      .then(r => {
+        return r
+      })
+      .catch(e => {
+        console.error(e)
+      })
+  }),
+  Benchmark.add('voided promise', () => {
+    // eslint-disable-next-line no-void
+    void asyncFunction()
+  }),
+  Benchmark.add('mishandled promise', () => {
     asyncFunction()
   }),
   Benchmark.cycle(),