benchmark on binary trees
Alex via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Dec 4 06:06:26 PST 2015
Hi everybody,
this is going to be a learning by doing a benchmark test - post.
Found this "game" on the web
http://benchmarksgame.alioth.debian.org/u64q/performance.php?test=binarytrees
and wanted to experiment on my self, I tried to reimplement some
code in D.
This:
http://dpaste.dzfl.pl/4d8e0ceb867c
I did by reimplementing the C# version
and this:
http://dpaste.dzfl.pl/2fd3841d85ef
by reimplementing the C++ version.
Besides the questions of improving both of them, which are
important but only because I would... maybe... at some point...
upload my code. For some DLang advertising effect ;)
The learning effect - questions are the following:
1. I wrote the C++ inspired version after the C# inspired, hoping
it would be faster. This was not the case. Why?
This is a big question, as there could be just some silly
mistakes of kind
"do not use this call, use this, and your program will be twice
as fast."
to some mistakes of general kind like
"why were you so foolish, and didn't wrote the whole code in just
one line."
2. I failed trying to implement some kind of parallelism in the
second version. I tried something like
auto depthind = iota(min_depth, max_depth+1, 2);
foreach(dummy_i, d; taskPool.parallel(depthind))
for the for-loop in the main function, but then, the program
never ends. Do you have a hint what was wrong?
3. The compilation was done by:
dmd -O -release -boundscheck=off [filename.d]
Is there anything else to improve performance significantly?
4. This is some ambiguous question. I come originally from the C#
corner, so I natively think in terms of the first approach. Can
one general make the statement, that for D one of the approaches
above will be always faster then the other?
More information about the Digitalmars-d-learn
mailing list