A smaller GC benchmark

Sean Kelly sean at f4.ca
Mon Dec 10 12:03:40 PST 2007


bearophile wrote:
> This tiny benchmark focus on GC performance and shows similar results to the "binary trees" benchmark I have shown here few weeks ago, but it's quite shorter, so it may be more useful. This code isn't meant to represent normal programs with thousands of classes, etc, it just shows something quite limited. This is an adaptation of the "Object Test" that you can find used and discussed here:
> http://www.twistedmatrix.com/users/glyph/rant/python-vs-java.html
> http://blog.snaplogic.org/?p=55
> http://programming.reddit.com/info/24ynh/comments
> Note that I test the GC of Phobos only, I don't use Tango yet.
> 
> 
> Object Test timings (on PIII @ 500 MHz), best of 3 runs (seconds, approximate Mbytes memory used), n=1_000, m=10_000:
>                seconds  MB
>   DMD class:   18.95    1.7
>   GDC class:   17.91    1.8
>   DMD struct:  11.77    1.7
>   GDC struct:  12.31    1.8
>   Python:      37.10    3.1  (ShedSkin version)
>   Psyco:       15.68    3.5
>   ShedSkin      6.35    1.6
>   Java (1):     2.19    7.3
>   Java (2):     2.10    7.8
> 
> See below for the sources. You can see the Java is about 9 (~= 18.95 / 2.10) times faster than the program produced by DMD. Even Psyco (the JIT for the turtle-slow language Python) gives faster performance (and the Python GC is simple, it's just a reference count plus cycle detection). You can also see Java (as usual) uses much more RAM (7.8/1.7 ~= 4.6).
> 
> Note that with some manual GC optimization the running time for the DMD class benchmark can become about one-two seconds smaller, but the memory used can be about 4 MB:

Manually calling gc.collect() actually slowed down the app for me.  And 
Tango performs about the same as Phobos, when using the Java test as a 
reference (ie. my quick test showed D being about 9 times as slow as 
Java using Tango).


Sean



More information about the Digitalmars-d mailing list