Async JS - The Good, the Bad and the Ugly

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Promise API
function fibonacci(num){
  return new Promise((resolve, reject) => {
  	var a = 1, b = 0, temp;

  while (num >= 0){
    temp = a;
    a = a + b;
    b = temp;
    num--;
  	}

  	resolve(b);	
  });
}

for (let i = 0; i < 100; i++) {
  fibonacci(i).then(() => {})
}
ready
Async code
async function fibonacci(num){
  var a = 1, b = 0, temp;

  while (num >= 0){
    temp = a;
    a = a + b;
    b = temp;
    num--;
  }

  return b;
}

for (let i = 0; i < 100; i++) {
  fibonacci(i).then(() => {})
}
ready
Synchronous code
function fibonacci(num){
  var a = 1, b = 0, temp;

  while (num >= 0){
    temp = a;
    a = a + b;
    b = temp;
    num--;
  }

  return b;
}

for (let i = 0; i < 100; i++) {
  fibonacci(i)
}
ready

Revisions

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