Differentiate shallow and deep clone implementation benchmarks
[benchmarks-js.git] / promise-handling.js
index b07b33d835583ae15f6edf8fd26b6cbc437953eb..0d0b3671b171749b9792c7254d11887d1387469c 100644 (file)
@@ -19,9 +19,22 @@ async function asyncFunction () {
 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('mishandled promise', () => {
     asyncFunction()
   }),
   Benchmark.cycle(),