Post about comparing C, C++ and D performance with a real world project

Daniel Kozak kozzi11 at gmail.com
Thu Dec 7 12:36:34 UTC 2017


On my machine D is faster than his c++ version, so It does look good. I use
his own repository so I do not know why his results are so different in my
case:

his c++ version with gcc:

real 0m0,021s
user 0m0,021s
sys 0m0,000s

his D version with DMD:
real 0m0,018s
user 0m0,015s
sys 0m0,004s

his D version with GDC:
real 0m0,015s
user 0m0,006s
sys 0m0,010s

his D version with LDC:
real 0m0,030s
user 0m0,025s
sys 0m0,005s

LDC is slower because on my system it use shared phobos library, so it
takes some time to load it.
all others (gcc,gdc and dmd use static libs)

When I use shared phobos for dmd, I get
real 0m0,032s
user 0m0,024s
sys 0m0,009s










On Thu, Dec 7, 2017 at 1:00 PM, Jonathan M Davis via Digitalmars-d <
digitalmars-d at puremagic.com> wrote:

> On Thursday, December 07, 2017 09:55:56 Antonio Corbi via Digitalmars-d
> wrote:
> > Hello all,
> >
> > Jussi Pakkanen (one of the meson build system creators) has
> > written a post comparing C, C++ and D. Worth a read.
> >
> > http://nibblestew.blogspot.com.es/2017/12/comparing-c-c-
> and-d-performance-> with.html
>
> Honestly, I find the results a bit depressing, but a lot of that probably
> stems from the fact that it's not idiomatic D code, and any time you do
> more
> or less direct conversions, you run the risk of things not working as
> efficiently due to differences in the languages involved. The author does
> acknowledge that, but without refactoring the code to be more idiomatic, it
> makes D look bad - though the fact that it does better with memory than C
> or
> C++ does make the GC look better than you'd necessarily expect. It's
> certainly surprising that the GC is the _good_ part of the results.
>
> I do wonder what the results would look like with clang and ldc though,
> particularly since the version of gdc in Ubuntu is going to be pretty old.
> It might make no difference at all, or there could be a definite
> improvement, depending on what his code is doing and what has changed since
> the last gdc release.
>
> - Jonathan M Davis
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20171207/bd76fa74/attachment.html>


More information about the Digitalmars-d mailing list