Phobos threads performance
bearophile
bearophileHUGS at lycos.com
Sun Jul 20 12:40:00 PDT 2008
I have taken a look at the Chameneos-redux multithread benchmarks, the explanations are are the bottom of this page:
http://shootout.alioth.debian.org/gp4/benchmark.php?test=chameneosredux&lang=all
(I think I have created a Psyco version almost 2X faster than the Python one).
This is the D + Phobos working implementation:
http://shootout.alioth.debian.org/gp4/benchmark.php?test=chameneosredux&lang=dlang&id=0
On my Win PC with N = 1_000_000 that D version runs in about 10 seconds. My CPU has two cores, but the CPU usage is about 70-75% (while both the Java and C++ version push the cores to 100%).
This is a C++ version, that I think looks very close to the D version (I think they are both translations of the Java version):
https://alioth.debian.org/tracker/download.php/30402/411646/310955/2682/chame.cpp
To run it on Windows I have used:
ftp://sources.redhat.com/pub/pthreads-win32/prebuilt-dll-2-8-0-release/
Added files to MinGW:
pthread.h
sched.h
semaphore.h
libpthreadGC2.a
Compiled code with:
g++ -O3 -s -mthreads chame.cpp -o chame -lpthreadGC2
With still n = 1_000_000 this C++ code runs in about 1.13 seconds.
Do you know why is the C++ so much faster, and why the D version doesn't uses the two cores fully?
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list