build(deps-dev): apply updates
[benchmarks-js.git] / promise-handling.mjs
1 import { bench, group, run } from 'tatami-ng'
2
3 /**
4 *
5 */
6 async function asyncFunction () {
7 await new Promise(resolve => {
8 resolve()
9 })
10 }
11
12 group('Promise handling', () => {
13 bench('await promise', async () => {
14 try {
15 return await asyncFunction()
16 } catch (e) {
17 console.error(e)
18 }
19 })
20 bench('promise with then().catch()', () => {
21 asyncFunction()
22 .then(r => {
23 return r
24 })
25 .catch(console.error)
26 })
27 bench('voided promise', () => {
28 // eslint-disable-next-line no-void
29 void asyncFunction()
30 })
31 bench('mishandled promise', () => {
32 asyncFunction()
33 })
34 })
35
36 await run({
37 units: true,
38 })