Add development tools configuration
[benchmarks-js.git] / promise-handling.js
CommitLineData
ed2968f2
JB
1const Benchmark = require('benchmark')
2const { LIST_FORMATTER } = require('./benchmark-utils')
3
4const suite = new Benchmark.Suite()
5
6function promise () {
7 return new Promise()
8}
9
10async function asyncFunction () {
11 await promise()
12}
13
14suite
15 .add('await promise', async function () {
16 await asyncFunction()
17 })
18 .add('promise', function () {
19 asyncFunction()
20 })
21 .on('cycle', function (event) {
22 console.log(event.target.toString())
23 })
24 .on('complete', function () {
25 console.log(
26 'Fastest is ' + LIST_FORMATTER.format(this.filter('fastest').map('name'))
27 )
28 // eslint-disable-next-line no-process-exit
29 process.exit()
30 })
31 .run()