my c++ d c# benchmark!

Started by
70 comments, last by Raghar 17 years, 6 months ago
Advertisement
Quote:Original post by Kambiz
I thought that JIT compilation can produce more efficient code because it can optimize for the target machine.
But it has less time to compile. Obviously it can't spend a minute optimizing some small program that would run in 20 seconds without full optimizations. But C compilation can take as long as necessary to make the best output code.
Kambiz, I encourage you to add the GDC D compiler to the charts :)
http://gdcwin.sourceforge.net/
Out of curiosity I implemented it in i386 machine code - it ended up 2 seconds slower than the C++ compiled version. At a guess (apart from shoddy code of course) I'd say it's because the compiler was more willing to unroll loops than I was. :)
nice benchmark. but of course it doesnt cover all performance relevant aspects.

i would like to see a memory allocation benchmark. with lots of news and deletes. i guess the managed version will be better there.
Quote:Original post by h3r3tic
Kambiz, I encourage you to add the GDC D compiler to the charts :)
http://gdcwin.sourceforge.net/
I can not compile using gdmd I get this error message:
object.d: module object cannot read file 'object.d'
I have never used those GNU compilers, can you tell me the correct command line arguments?
I have tried “gdmd pi.d -O -release” with “C:\MinGW\include\d\3.4.5” added to the PATH variable.
-I have to work now later I will try this again.-

Quote:Original post by cody
nice benchmark. but of course it doesnt cover all performance relevant aspects.

i would like to see a memory allocation benchmark. with lots of news and deletes. i guess the managed version will be better there.
I agree.
Quote:Original post by Kambiz
I can not compile using gdmd I get this error message:
object.d: module object cannot read file 'object.d'
I have never used those GNU compilers, can you tell me the correct command line arguments?
I have tried “gdmd pi.d -O -release” with “C:\MinGW\include\d\3.4.5” added to the PATH variable.
-I have to work now later I will try this again.-

The error message means that it cannot find gphobos, the GDC standard library. It could mean a MinGW or GDC installation problem, but I'm not sure what exactly in this case. You could try adding 'C:\MinGW\include\d\3.4.5' to your path. I have mostly used DMD so I can't really help much in this case. On a last note, maybe it's a problem with GDC based on GCC 3.4.5 ? I've got the one based on 3.4.2 and it seems to work fine
As for the command line arguments, both:
> gdmd -inline -release -O pi.d
and
> gdc -frelease -finline -O3 pi.d
worked for me
Quote:Original post by cody
nice benchmark. but of course it doesnt cover all performance relevant aspects.
Here's a benchmark showing that low level code generation doesn't always matter, sometimes higher level features matter much more:

http://www.digitalmars.com/d/cppstrings.d

Scroll down to see the benchmark.

I believe you mean http://digitalmars.com/d/cppstrings.html
Quote:Original post by Kambiz
I'm just surprised a little: I thought that D shouldn't be much slower than c++ and I thought that c# would be much faster. Maybe there is some optimization option I have not used(?)

What do you think about the results?


Which version of DMD? With v0.169 of DMD (the latest just posted) and the .NET 2.0 runtime I got:

Intel 2.2 Ghz:
CPP 2.28 (cl /Ox /TP)
D 2.26 (dmd -O -inline -release)
C# 4.52 (csc /optimize+ /checked- /unsafe+)

AMD 3200+
CPP 1.43
D 1.46
C# 3.25

Check this for some other comparisons:

Computer Language Shootout

This topic is closed to new replies.

Advertisement