await vs then (v3)

Revision 3 of this benchmark created on


Setup

const promise = () => new Promise((resolve) => {
	setTimeout(() => {resolve('done')}, 50); 
});

Test runner

Ready to run.

Testing in
TestOps/sec
await
const exec = async () => {
	const result = await promise();
	console.log(result);
}

exec();
ready
then
const exec = () => {
	promise().then((result) => {
		console.log(result);	
	})
}

exec();
ready

Revisions

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