Am Sat, 26 Oct 2013 18:34:55 +0200 schrieb "Kai Nacke" <k...@redstar.de>:
> On Saturday, 26 October 2013 at 02:21:37 UTC, deadalnix wrote: > > The explanation is quite simple. LLVM understand C and C++ > > runtime. It doesn't understand D runtime (LDC is doing some > > work in that regard, but it is still limited). So you see a > > difference between C and C++ as some optimization will be done > > in C/C++ (for instance heap to stack promotion) when it won't > > be done in D. > > While this is true in general I don't think that it explains the > difference in the mentioned benchmark. A PRNG does not use too > much of the C runtime. And at a closer look, the author replaced calls to the C PRNG with a simple XorShift engine included in the source code to level the field between the languages. 60% of the runtime is spent checking for collisions between rectangles. > I believe that the IR generated by LDC could be improved and that > the difference in speed is caused by this. If the author had applied correct rounding both Clang and LDC would have had 100%. I assume the 1 ms (< 0.5%) difference stems from the startup time of D or maybe for C he timed the code internally and for D he used "time"; but it is really insignificant in relative numbers. > Regards > Kai -- Marco