Appender is ... slow
Jonathan M Davis via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Aug 14 12:10:17 PDT 2014
On Thursday, 14 August 2014 at 17:16:42 UTC, Philippe Sigaud
wrote:
> From time to time, I try to speed up some array-heavy code by
> using std.array.Appender, reserving some capacity and so on.
>
> It never works. Never. It gives me executables that are maybe
> 30-50% slower than bog-standard array code.
>
> I don't do anything fancy: I just replace the types, use
> clear() instead of = null...
>
> Do people here get good results from Appender? And if yes, how
> are you using it?
I've never really tried to benchmark it, but it was my
understanding that the idea behind Appender was to use it to
create the array when you do that via a lot of appending, and
then you use it as a normal array and stop using Appender. It
sounds like you're trying to use it as a way to manage reusing
the array, and I have no idea how it works for that. But then
again, I've never actually benchmarked it for just creating
arrays via appending. I'd just assumed that it was faster than
just using ~=, because that's what it's supposedly for. But maybe
I just completely misunderstood what the point of Appender was.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list