Last active
September 12, 2023 15:54
-
-
Save ColonelBundy/d57fb9cd16eb87b2d4d932acc1055b30 to your computer and use it in GitHub Desktop.
Promise vs Callback vs Async/await benchmark 2018
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Script used: | |
https://github.com/kyrylkov/promise-async-performance | |
Platform info: | |
Windows_NT 10.0.16299 x64 | |
AMD Ryzen 7 1700 Eight-Core Processor × 16 | |
Conclusion: | |
Callback's takes the cake, async/await is horrible |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Doxbee sequential | |
benchmarking ./doxbee-sequential/async-bluebird.js | |
{"time":428,"mem":60.38671875,"errors":0,"lastErr":null} | |
benchmarking ./doxbee-sequential/async-es2017-native.js | |
{"time":591,"mem":98.82421875,"errors":0,"lastErr":null} | |
benchmarking ./doxbee-sequential/async-es2017-util.promisify.js | |
{"time":479,"mem":69.7734375,"errors":0,"lastErr":null} | |
benchmarking ./doxbee-sequential/callbacks-baseline.js | |
{"time":149,"mem":29.99609375,"errors":0,"lastErr":null} | |
benchmarking ./doxbee-sequential/promises-bluebird-generator.js | |
{"time":267,"mem":40.62109375,"errors":0,"lastErr":null} | |
benchmarking ./doxbee-sequential/promises-bluebird.js | |
{"time":329,"mem":49.48046875,"errors":0,"lastErr":null} | |
benchmarking ./doxbee-sequential/promises-es2015-native.js | |
{"time":560,"mem":90.82421875,"errors":0,"lastErr":null} | |
benchmarking ./doxbee-sequential/promises-es2015-util.promisify.js | |
{"time":513,"mem":71.2734375,"errors":0,"lastErr":null} | |
results for 10000 parallel executions, 1 ms per I/O op | |
file time(ms) memory(MB) | |
callbacks-baseline.js 149 30.00 | |
promises-bluebird-generator.js 267 40.62 | |
promises-bluebird.js 329 49.48 | |
async-bluebird.js 428 60.39 | |
async-es2017-util.promisify.js 479 69.77 | |
promises-es2015-util.promisify.js 513 71.27 | |
promises-es2015-native.js 560 90.82 | |
async-es2017-native.js 591 98.82 | |
Madeup parallel | |
benchmarking ./madeup-parallel/async-bluebird.js | |
{"time":597,"mem":115.71875,"errors":0,"lastErr":null} | |
benchmarking ./madeup-parallel/async-es2017-native.js | |
{"time":2056,"mem":317.40234375,"errors":0,"lastErr":null} | |
benchmarking ./madeup-parallel/async-es2017-util.promisify.js | |
{"time":1421,"mem":201.40625,"errors":0,"lastErr":null} | |
benchmarking ./madeup-parallel/callbacks-baseline.js | |
{"time":371,"mem":74.2578125,"errors":0,"lastErr":null} | |
benchmarking ./madeup-parallel/promises-bluebird-generator.js | |
{"time":604,"mem":111.328125,"errors":0,"lastErr":null} | |
benchmarking ./madeup-parallel/promises-bluebird.js | |
{"time":564,"mem":106.125,"errors":0,"lastErr":null} | |
benchmarking ./madeup-parallel/promises-es2015-native.js | |
{"time":1762,"mem":305.1484375,"errors":0,"lastErr":null} | |
benchmarking ./madeup-parallel/promises-es2015-util.promisify.js | |
{"time":1314,"mem":192.19921875,"errors":0,"lastErr":null} | |
results for 10000 parallel executions, 1 ms per I/O op | |
file time(ms) memory(MB) | |
callbacks-baseline.js 371 74.26 | |
promises-bluebird.js 564 106.13 | |
async-bluebird.js 597 115.72 | |
promises-bluebird-generator.js 604 111.33 | |
promises-es2015-util.promisify.js 1314 192.20 | |
async-es2017-util.promisify.js 1421 201.41 | |
promises-es2015-native.js 1762 305.15 | |
async-es2017-native.js 2056 317.40 | |
Platform info: | |
Windows_NT 10.0.16299 x64 | |
Node.JS 8.9.4 | |
V8 6.1.534.50 | |
AMD Ryzen 7 1700 Eight-Core Processor × 16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Doxbee sequential | |
benchmarking ./doxbee-sequential/async-bluebird.js | |
{"time":363,"mem":57.234375,"errors":0,"lastErr":null} | |
benchmarking ./doxbee-sequential/async-es2017-native.js | |
{"time":413,"mem":93.171875,"errors":0,"lastErr":null} | |
benchmarking ./doxbee-sequential/async-es2017-util.promisify.js | |
{"time":382,"mem":65.4609375,"errors":0,"lastErr":null} | |
benchmarking ./doxbee-sequential/callbacks-baseline.js | |
{"time":152,"mem":25.5625,"errors":0,"lastErr":null} | |
benchmarking ./doxbee-sequential/promises-bluebird-generator.js | |
{"time":248,"mem":36.40625,"errors":0,"lastErr":null} | |
benchmarking ./doxbee-sequential/promises-bluebird.js | |
{"time":251,"mem":46.23828125,"errors":0,"lastErr":null} | |
benchmarking ./doxbee-sequential/promises-es2015-native.js | |
{"time":413,"mem":89.1015625,"errors":0,"lastErr":null} | |
benchmarking ./doxbee-sequential/promises-es2015-util.promisify.js | |
{"time":436,"mem":63.33203125,"errors":0,"lastErr":null} | |
results for 10000 parallel executions, 1 ms per I/O op | |
file time(ms) memory(MB) | |
callbacks-baseline.js 152 25.56 | |
promises-bluebird-generator.js 248 36.41 | |
promises-bluebird.js 251 46.24 | |
async-bluebird.js 363 57.23 | |
async-es2017-util.promisify.js 382 65.46 | |
async-es2017-native.js 413 93.17 | |
promises-es2015-native.js 413 89.10 | |
promises-es2015-util.promisify.js 436 63.33 | |
Madeup parallel | |
benchmarking ./madeup-parallel/async-bluebird.js | |
{"time":445,"mem":109.73046875,"errors":0,"lastErr":null} | |
benchmarking ./madeup-parallel/async-es2017-native.js | |
{"time":1420,"mem":312.7578125,"errors":0,"lastErr":null} | |
benchmarking ./madeup-parallel/async-es2017-util.promisify.js | |
{"time":1029,"mem":195.8515625,"errors":0,"lastErr":null} | |
benchmarking ./madeup-parallel/callbacks-baseline.js | |
{"time":298,"mem":73.140625,"errors":0,"lastErr":null} | |
benchmarking ./madeup-parallel/promises-bluebird-generator.js | |
{"time":502,"mem":104.19921875,"errors":0,"lastErr":null} | |
benchmarking ./madeup-parallel/promises-bluebird.js | |
{"time":455,"mem":103.63671875,"errors":0,"lastErr":null} | |
benchmarking ./madeup-parallel/promises-es2015-native.js | |
{"time":1300,"mem":300.89453125,"errors":0,"lastErr":null} | |
benchmarking ./madeup-parallel/promises-es2015-util.promisify.js | |
{"time":1073,"mem":184.8359375,"errors":0,"lastErr":null} | |
results for 10000 parallel executions, 1 ms per I/O op | |
file time(ms) memory(MB) | |
callbacks-baseline.js 298 73.14 | |
async-bluebird.js 445 109.73 | |
promises-bluebird.js 455 103.64 | |
promises-bluebird-generator.js 502 104.20 | |
async-es2017-util.promisify.js 1029 195.85 | |
promises-es2015-util.promisify.js 1073 184.84 | |
promises-es2015-native.js 1300 300.89 | |
async-es2017-native.js 1420 312.76 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I remember reading elsewhere about this, I think when io.js was a thing. Figured I'd look it up again just as a reminder that I'm making my code less perfermant for readability sake. Didnt realize async await was so bad. I actually just read an article that promises are faster than callbacks. Thought that was humorous. I believe with promises, three functions are constructed while with callbacks, one.
It would be nice if a compiler could automatically convert promises into callbacks. I imagine this is possible with typescript so long as a function fits the definition of a CallbackOrPromise.