await vs then (v5)

Revision 5 of this benchmark created on


Setup

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

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 = () => {
	const result = promise();
	
	result.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.