Thank Steve,
I open a new thread with some corrections, better title, etc.

On Wednesday, 31 March 2021 at 22:05:12 UTC, Steven Schveighoffer wrote:
On 3/31/21 5:32 PM, ludo wrote:
[...]

ArrayBuilder should be similar in performance to Appender. I think part of the issue with appender could be the ref counted design. Only 1000 elements is going to show heavily the setup/teardown time of allocation of the implementation struct. But that is a guess. You may want to up the repetition count to 100 or 1000.

Note your code for appending with length is not doing what you think:

void concat_withLength()
                {
                        int[] array;
                        array.length = 1000;
                        for (int j=0; j<1000; j++)
                                array ~= j;
                }

This allocates 1000 elements, and then append 1000 *more* elements.

I think you meant in the loop:

array[j] = j;

This should be the fastest one.

-Steve

Reply via email to