On Sunday, 13 August 2017 at 09:15:48 UTC, amfvcg wrote:

Change the parameter for this array size to be taken from stdin and I assume that these optimizations will go away.

This is paramount for all of the testing, examining, and comparisons that are discussed in this thread. Full information is given to the compiler, and you are basically testing the constant folding power of the compilers (not unimportant). No runtime calculation is needed for the sum. Your program could be optimized to the following code:
```
void main()
{
    MonoTime beg = MonoTime.currTime;
    MonoTime end = MonoTime.currTime;
    writeln(end-beg);
    writeln(50000000);
}
```
So actually you should be more surprised that the reported time is not equal to near-zero (just the time between two `MonoTime.currTime` calls)!

Instead of `iota(1,1000000)`, you should initialize the array with random numbers with a randomization seed given by the user (e.g. commandline argument or stdin). Then, the program will actually have to do the runtime calculations that I assume you are expecting it to perform.

- Johan

Reply via email to