leonardo ([info]leonardo_m) wrote,
@ 2009-07-04 23:57:00
Previous Entry  Add to memories!  Tell a Friend  Next Entry
Entry tags:benchmark, c, d language, dmd, ldc, python

Richards benchmark
This old post of mine is about virtual methods and devirtualizations:
http://leonardo-m.livejournal.com/76547.html

I have performed more benchmarks about virtual methods and its costs with LDC. I have used a little well known benchmark, the Richards one. I have used the code from here (on the Web Archive because it seems to be not online anymore):
http://web.archive.org/web/20060715074131/lissett.port5.com/ben/bench1.htm
http://web.archive.org/web/20060715074131/http://lissett.port5.com/ben/bench3.htm

All the code of the following benchmarks:
http://www.fantascienza.net/leonardo/js/richards.zip

Timing results:

Windows, n = 10_000_000:
  C:       1.26
  D ~C:    2.01
  Java:    2.04 (final classes, -server)
  D2 ~C#:  2.36 (final classes)
  D3 ~C#:  2.36 (final classes, no getters/setters)  
  Java:    2.73 (final classes)
  D4 ~C#:  3.07 (no getters/setters)  
  C#:      3.98
  D1 ~C#:  4.23
  
Windows, n = 100_000_000:
  C:      12.16
  Java:   18.73 (final classes, -server)
  D ~C:   18.86
  D2 ~C#: 23.11 (final classes)
  D3 ~C#: 23.12 (final classes, no getters/setters)  
  Java:   25.40 (final classes)
  D4 ~C#: 30.16 (no getters/setters)    
  C#:     38.39
  D1 ~C#: 41.64


Pubuntu, n = 10_000_000:
  D ~C:    1.35
  C:       1.39
  D2 ~C#:  1.98 (final classes)  
  D3 ~C#:  2.00 (final classes, no getters/setters) 
  Java:    2.73 (final classes)  
  D4 ~C#:  2.94 (no getters/setters)      
  C#:      -  
  D1 ~C#:  4.03
  
Pubuntu, n = 100_000_000:
  D ~C:   13.24
  C:      13.77
  D2 ~C#: 19.64 (final classes)
  D3 ~C#: 19.92 (final classes, no getters/setters) 
  Java:   25.16 (final classes)    
  D4 ~C#: 29.16 (no getters/setters)       
  C#:      -
  D1 ~C#:  40.17

Key:
  D ~C# means D code that comes from the C# version.
  D ~C means D code that comes and looks from the C version.

Note that the classes in C# code aren't final. As usual Java shows very good performance.


On WindowsXp:
DMD Digital Mars D Compiler v1.042
gcc version 4.3.3-dw2-tdm-1 (GCC)

dmd used with:
dmd -O -release -inline

ldc used with:
ldc -O5 -release -inline

gcc used with:
gcc -Wall -O3 -s -fomit-frame-pointer -msse3 -march=core2


On Pubuntu:
gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu4)
ldc based on DMD v1.045 and llvm 2.6svn (Thu Jul 2 23:07:48 2009)

ldc used with:
ldc -O5 -release -inline

gcc used with:
gcc -Wall -O3 -s -fomit-frame-pointer -msse3 -march=native



(Read 8 comments) - (Post a new comment)

Re: C# Linux timings
[info]leonardo_m
2009-07-17 09:54 pm UTC (link)
Since they changed the JIT from a tree-based internal representation to the new linear IR things got faster and still will

See also:
http://tirania.org/blog/archive/2009/Jul-16.html


Sure, because at the moment they still use the same conservative Boehm-Demers-Wiser Conservative Garbage Collector like the D programming language

I think D is currently using a GC a bit better than then Bohem one.


No it isn't (at least if you do it the primitive way). You just have to change the "class" keyword to "struct". That is basically all you have to do (no other changes - structs are instantiated with new like objects, so again no changes here).

I have tried and I have failed. I don't know C# yet.

(Reply to this) (Parent)(Thread)

Re: C# Linux timings
(Anonymous)
2009-07-18 12:27 am UTC (link)
"See also:
http://tirania.org/blog/archive/2009/Jul-16.html "

Oh. This really looks nice. Thank you very much for the information.



"I think D is currently using a GC a bit better than then Bohem one."

I don't know if they have changed it, but the last time i looked at it i am quite sure that the original D with the phobos runtime uses boehm. Tango is afaik using another gc (which is slightly better but sadly not much) but i could be totally wrong here. But anyway, i think D would really benefit from a better tailored GC.



"I have tried and I have failed. I don't know C# yet."

Sorry. It's not your fault. Since i have given you the nice pointy-headed super hint how simple it is to use structs in your benchmark without taking a detailed look at your code, i should better admit, that i too, don't seem to know C# yet :-) So again sorry.

Maybe i will take a look at your C# Code if i have time and try to fail too :-)
And if i should really get something to work with structs, i'll let you know.

(Reply to this) (Parent)


(Read 8 comments) - (Post a new comment)

Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…