benchmark on binary trees

anonymous via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Dec 4 11:31:22 PST 2015


On 04.12.2015 15:06, Alex wrote:
> 1. I wrote the C++ inspired version after the C# inspired, hoping it
> would be faster. This was not the case. Why?
[...]

Why did you expect the C++ inspired version to be faster? Just because 
the original was written in C++?

 From a quick skim the two versions seem to be pretty much identical, 
aside from names and struct vs class.

Names don't make a difference of course. It would be easier to compare 
the two versions if you used the same names, though.

The differences between structs on the heap and classes are subtle. It's 
not surprising that they don't have an impact here.

If there are substantial differences between the two versions, please 
point them out.

> 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?

Works for me. Maybe show the exact full program you tried, and tell what 
compiler version you're using.

> 3. The compilation was done by:
> dmd -O -release -boundscheck=off [filename.d]
> Is there anything else to improve performance significantly?

The other compilers, ldc and gdc, usually produce faster code than dmd.

> 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?

Just reiterating what I said re the first question: I don't really see a 
difference. If you think there is, please point it out. Or if you're not 
sure, feel free to ask about specific parts.


More information about the Digitalmars-d-learn mailing list