RFC on range design for D2
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Wed Sep 10 07:04:00 PDT 2008
bearophile wrote:
> Few benchmarks, appending ints, note this is a worst-case situation (other benchmarks are less dramatic). Just many appends, followed by the "release":
>
> benchmark 10, N=10_000_000:
> Array append: 0.813 s
> ArrayBuilder: 0.159 s
> ArrayAppender: 1.056 s
>
> benchmark 10, N=100_000_000:
> Array append: 10.887 s
> ArrayBuilder: 1.477 s
> ArrayAppender: 13.305 s
That's odd. The array appender should never, by definition, do
significantly worse than the straight array append. I think some other
factor intervened (e.g. swapping). Also don't forget to compile with -O
-release -inline and to test several times after a warmup run. I adapted
your code obtaining the numbers below:
benchmark 10, N=10000000:
Array append: 0.69 s
ArrayAppender: 0.19 s
benchmark 10, N=25000000:
Array append: 2.06 s
ArrayAppender: 0.82 s
benchmark 10, N=50000000:
Array append: 4.28 s
ArrayAppender: 1.75 s
benchmark 10, N=75000000:
Array append: 9.62 s
ArrayAppender: 5.8 s
benchmark 10, N=100000000:
Array append: 11.35 s
ArrayAppender: 6.20 s
Andrei
More information about the Digitalmars-d-announce
mailing list