Timing too good to be true

David Nadlinger code at klickverbot.at
Sat Sep 21 16:14:55 PDT 2013


On Sun, Sep 22, 2013 at 12:07 AM, Paul Jurczak <pauljurczak at yahoo.com> wrote:
> I'm running this test program with multiple compilers on Xubuntu and I'm
> getting impossibly short timings with LDC compared to DMD and GDC (timing
> details in comments below). I would appreciate any ideas about what is going
> on here?
> [...]

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.

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


More information about the digitalmars-d-ldc mailing list