Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Time to create simple promises
(version: 0)
Comparing performance of:
One promise vs two promise vs zero promise vs shorter
Created:
6 years ago
by:
Guest
Jump to the latest result
Tests:
One promise
console.log(test()); async function test(){ let param = 'test'; const result = await doSomething(param); return result; } async function doSomething(p) { const result1 = p; const result2 = p + 'a'; const result3 = p + 'b'; const result4 = p + 'c'; const result5 = p + 'd'; return new Promise(function(resolve, reject) { resolve([result1, result2, result3, result4, result5]); }); }
two promise
console.log(test()); async function test(){ let param = 'test'; const result = await doSomething(param); return result; } async function doSomething(p) { const result1 = await doSomethingElse(p); const result2 = await doSomethingElse(p, 'a'); const result3 = await doSomethingElse(p, 'b'); const result4 = await doSomethingElse(p, 'c'); const result5 = await doSomethingElse(p, 'd'); return new Promise(function (resolve, reject) { resolve([result1, result2, result3, result4, result5]); }); async function doSomethingElse(p, p2 = '') { const result = p + p2; return new Promise(function (resolve, reject) { resolve(result); }); } }
zero promise
console.log(test()); function test(){ let param = 'test'; const result = doSomething(param); return result; } function doSomething(p) { const result1 = p; const result2 = p + 'a'; const result3 = p + 'b'; const result4 = p + 'c'; const result5 = p + 'd'; return [result1, result2, result3, result4, result5]; }
shorter
console.log(test()); function test(){ return doSomething('test'); } function doSomething(p) { return [p, p + 'a', p + 'b', p + 'c', p + 'd']; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
One promise
two promise
zero promise
shorter
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
custom promise vs jquery deferred object
Promise vs. Callback
Promise vs Async Await
Promise vs Async Await(2)
Async vs Callback
Comments
Confirm delete:
Do you really want to delete benchmark?