On 10/05/2014 02:40 PM, Sativa wrote:

>      foreach(i; thds) { ulong s = 0; for(ulong k = 0; k <
> iter/numThreads; k++)

The for loop condition is executed at every iteration and division is an expensive operation. Apparently, the compiled does some optimization when the divisor is known at compile time.

Being 4, it is just a shift of 2 bits. Try something like 5, it is slow even for enum.

This solves the problem:

        const end = iter/numThreads;

        for(ulong k = 0; k < end; k++) {

Ali

Reply via email to