es6-async/await语法糖

Benchmark created on


Setup

function promiseAdd (a, b) {
  return new Promise((resolve, reject) => {
    const res = a + b
    resolve(res)
  })
}
async function asyncAdd (a, b) {
  const res = a + b
  return res
}

Test runner

Ready to run.

Testing in
TestOps/sec
promise
async function run () {
	let res
	promiseAdd(1,2).then((r)=>{
  		res = r
	})
}
run()
ready
async/await
async function run () {
	let res = await asyncAdd(1, 2)
}
run()
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.