benchmark on binary trees
anonymous via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Dec 5 02:10:17 PST 2015
On 05.12.2015 01:40, Alex wrote:
> found and tried out the -vgc option...
> Is there a way to deactivate the GC, if it stands in way?
You can call core.memory.GC.disable to disable automatic collections.
.enable to turn them on again.
http://dlang.org/phobos/core_memory.html#.GC
> Yes, I thought in the same direction. That's why I tried to reimplement
> the c++ version. The idea was: as I can't compete with the GC of C#, I
> could try to compete by applying another approach. I don't try to write
> something which compete with c++ either (I would have to take c++, then?
> ;) ), but something which clearly outperforms the languages with a
> virtual machine...
Your C++ inspired version still allocated via the GC, though. If that
eats performance, then you'd have to mirror more closely what the C++
version actually does. It most probably doesn't use a GC.
I presume this is the C++ version you took as inspiration:
http://benchmarksgame.alioth.debian.org/u64q/program.php?test=binarytrees&lang=gpp&id=6
That uses a boost::object_pool for the nodes. Assuming that that's being
used for a reason, you could probably get a performance boost by doing
something similar. I'm not really familiar with
std.experimental.allocator, maybe there's something like object_pool in
there. Otherwise, you'd have to implement it yourself.
Generally, I think most of the time you can write a program in D that's
as fast as one written in C++. But you may have to give up on some
convenience, and the libraries may not be there to support you.
More information about the Digitalmars-d-learn
mailing list