Timing too good to be true

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


On Saturday, 21 September 2013 at 23:15:05 UTC, David Nadlinger 
wrote:
>> [...]
>
> First, a remark unrelated to the actual issue at hand: Your 
> program
> uses at least 2.4 MB of stack (for the result/timing 
> variables), which
> is large enough to cause issues e.g. on Win32, where the 
> default stack
> size is 1 MB.

Thanks, that explains the segfault when I was using N = 1_000_000.

> That being said, the LDC-compiled version is so fast because 
> the LLVM
> optimizer constant-folds the entire e28 functions away. Thus, 
> you are
> timing the single store of the constant 669171001 to a memory 
> location
> (or rather, the overhead involved in calling the StopWatch 
> functions).
>
> Hope this answers your question,
> David

It sounds convincing, but I tried it again with small Ns. For N = 
1, function is called only once, so the minimum of all timings 
should be accurate, but the result is still unbelievably short:

N = 1
669171001  57ns  e28_0
669171001  58ns  e28_1

N = 2
669171001  42ns  e28_0
669171001  43ns  e28_1

N = 10
669171001  26ns  e28_0
669171001  25ns  e28_1




More information about the digitalmars-d-ldc mailing list