https://stackoverflow.com/questions/...nchronous-code
Async/await does not give you any parallelism, only concurrency. That means that any sync operation using async/await to divide the work will just run one part after the other, not faster than without async/await and in fact slower because it adds overhead.
You can only get parallelism via threads, and you are limited to the number of cores you have in your system.
Some async runtimes do run the code in parallel, using multiple threads, so you will get some parallelism (and therefore speed) if you'll use them correctly; but this just adds overhead over using threads directly, or using a library such as rayon that avoids async/await and parallelizes the code using threads only.
If you're not I/O bound, don't use async/await. You have nothing to gain.
Partager