On Sunday, 3 February 2013 at 08:53:11 UTC, timotheecour wrote:
Note that dynamic arrays are generic containers, so they
aren't exactly optimized for anything. You could try that test
with the "made for appending" std.array.appender: It always
tries to extend without reallocating, and only relocates when
the current memory segment is 100% full.
Furthermore, when it *does* relocate, it use D-style memmove
without calling postblit. Independent of language, and with
the requirement of contiguous memory, I can't really think of
a scheme that could be better than that...?
modified a bit (see below) to include timing etc. I'm on OSX
(16GB ram, core i7 2.3GHz).
One more: Did you try using std.container.Array?
Even if appender is more optimized than naked array appending, it
still has to work with the underlying system. std.container.Array
should be able to do just as well as vector, or better (D move
semnantics).