Benchmarks - LDC vs GDC

Cecil Ward cecil at cecilward.com
Mon Jun 26 20:22:24 UTC 2023


I just read an interesting article about a benchmark comparison 
between GDC and LDC. The code being tested did a lot of (32-bit?) 
integer divisions and unfirtunately LDC rather bent the 
comparison by using an algorithmic replacement for the x86 idiv 
instruction which may or may not be preferable depending on the 
vintage of CPU. It also biases the comparison in favour of the 
detailed handing if that one single topic.

I wonder if anyone else is interested in doing some more LDC vs 
GDC comparisons ? With a common benchmark driver if possible.

GDC: -O3 -frelease -mtune=native -march=native
LDC: -O3 -release -boundscheck=off -mcpu=native

If using floating point, then we should add in the fast-math 
switches - can’t remember the exact details, so perhaps someone 
would append them?

I would especially like a meat-and-potatoes one that does not 
depend on maths in tight loops and on the power of loop-specific 
optimisations. By meat and potatoes I mean: integer arithmetic, 
lots of test and branches, some memory accesses. Something like 
parsing or string processing. The maths-oriented ones and 
floating point are welcome too, and I’d really like to see D 
80-bit real tested in a compiler benchmark. Complex numbers in D 
too.

But most of all, a real-world piece of code, run n times and 
turned into a benchmark. Run time ought to be > 1 min so as to 
make sure that timing inaccuracies do not drown the results in 
noise.

Anyone up for it?




More information about the Digitalmars-d mailing list