foreach (i; taskPool.parallel(0..2_000_000)

Paul phshaffer at gmail.com
Mon Apr 3 22:02:58 UTC 2023


On Sunday, 2 April 2023 at 15:32:05 UTC, Steven Schveighoffer 
wrote:

>
> It's important to note that parallel doesn't iterate the range 
> in parallel, it just runs the body in parallel limited by your 
> CPU count.
**?!?**

> If your `foreach` body takes a global lock (like 
> `writeln(i);`), then it's not going to run any faster (probably 
> slower actually).
**Ok I did have some debug writelns I commented out.**

> If you can disclose more about what you are trying to do, it 
> would be helpful.
**This seems like it would be a lot of code and explaining but 
let me think about how to summarize.**

> Also make sure you have more than one logical CPU.
**I have 8.**




More information about the Digitalmars-d-learn mailing list