On 4/1/23 6:32 PM, Paul wrote:
On Saturday, 1 April 2023 at 18:30:32 UTC, Steven Schveighoffer wrote:
On 4/1/23 2:25 PM, Paul wrote:
```d
import std.range;
foreach(i; iota(0, 2_000_000).parallel)
```
Is there a way to tell if the parallelism actually divided up the work?
Both versions of my program run in the same time ~6 secs.
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).
If you can disclose more about what you are trying to do, it would be
helpful.
Also make sure you have more than one logical CPU.
-Steve