Timing too good to be true

Paul Jurczak pauljurczak at yahoo.com
Sat Sep 21 21:48:47 PDT 2013


On Sunday, 22 September 2013 at 00:58:42 UTC, Paul Jurczak wrote:
> On Sunday, 22 September 2013 at 00:39:43 UTC, David Nadlinger 
> wrote:
>>> [...]
>>
>> As mentioned in my previous message, this is actually 
>> irrelevant for
>> your benchmark, as the functions are not even executed once by 
>> the
>> optimized test program.
>>
>> David
>
> If it is not executed even once, how is the value computed? At 
> compile time?

OK, you've wrote "optimizer constant-folds the entire e28 
functions away", which means compile time. Very clever optimizer! 
To defeat this behavior I changed timing loop to:

       foreach (i; 0..N) {
          sw.reset;
          sw.start;
          results[i] = fun(1002 + i%2); // a trick to defeat LLVM 
optimizer
          sw.stop;
          timings[i] = sw.peek.nsecs;
       }

and now I'm getting sensible results:

GDC 4.8.1:     gdc-4.8 -m64 -march=native -fno-bounds-check 
-frename-registers -frelease -O3
669171001  830ns  e28_0
669171001  830ns  e28_1

DMD64 2.063.2: dmd -O -noboundscheck -inline -release
669171001  1115ns  e28_0
669171001  1958ns  e28_1

LDC 0.11.0: ldmd2 -m64 -O -noboundscheck -inline -release
669171001  454ns  e28_0
669171001  395ns  e28_1

LDC is smoking fast here!


More information about the digitalmars-d-ldc mailing list