| leonardo ( @ 2008-04-08 03:25:00 |
Slow D
Here I have collected few benchmarks where the D language, or the DMD compiler, or the Phobos std lib don't shine in their performance. Two of the following performance problems (see 'gc1' and 'sort' benchmarks) have already a solution.
http://www.fantascienza.net/leonard o/js/slow_d.zip
--------------------
Compilers/interpreters used:
Digital Mars D Compiler v1.028
gcc version 4.2.1-dw2 (mingw32-2)
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32
Psyco V.1.5.2 (JIT for Python)
javac 1.6.0_03, Java version "1.6.0_03"
All timings are "warm", best of 3, in seconds.
CPU used is a Pentium3 500 MHz, 256 MB RAM, with Win.
Compilation flags used (when not specified otherwise):
gcc: -O3 -s
dmd: -O -release -inline
Python: no flags.
-------------------
www.fantascienza.net/leonardo/so/libs_d.z ip ).
Here I have collected few benchmarks where the D language, or the DMD compiler, or the Phobos std lib don't shine in their performance. Two of the following performance problems (see 'gc1' and 'sort' benchmarks) have already a solution.
http://www.fantascienza.net/leonard
--------------------
Compilers/interpreters used:
Digital Mars D Compiler v1.028
gcc version 4.2.1-dw2 (mingw32-2)
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32
Psyco V.1.5.2 (JIT for Python)
javac 1.6.0_03, Java version "1.6.0_03"
All timings are "warm", best of 3, in seconds.
CPU used is a Pentium3 500 MHz, 256 MB RAM, with Win.
Compilation flags used (when not specified otherwise):
gcc: -O3 -s
dmd: -O -release -inline
Python: no flags.
-------------------
BENCHMARKS: recursive, n = 38: C: 3.89 s (with __builtin_expect) C: 3.99 s D: 4.95 s hash, n = 500_000: D: 7.07 s (7.15 s with GC patched) D: 5.89 s (GC disabled) Psyco: 4.23 s(Note that Python+Psyco has much bigger overhead compared to D in any instruction, simple loops too).
wordcount, on a txt file of 13_312_768 bytes:
C: 0.73 s
D: 5.77 s
gc1, with 6.3 MB of text:
loading splitting total
time time time
D: 1.87 s 3.58 s 13.76 s
Python: 0.28 s 1.98 s 3.52 s
Python: 0.1 s 2.0 s 3.38 s (load with 'rb', same result)
With a Patch to the D GC, plus disabling the GC:
D: 0.08 s 0.72 s 1.36 s (GC patched + GC disabled after load)
gc2, 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
Psyco: 15.68 3.5
Java: 2.19 7.3
gc3 (binarytrees), n = 15:
Java: 9.12 s
D: 35.01 s
sort, const n = 1_000_000:
Random distribution:
sort: 2.934
fastSort: 0.881
Already sorted arrays:
sort: 1.723
fastSort: 0.41
Inverted order arrays:
sort: 1.853
fastSort: 0.651
(For a better and more complete version of fastSort see my D libs:www.fantascienza.net/leonardo/so/libs_d.z