How efficient are push!() and append!() methods in Julia?
<p>On <a href="http://docs.julialang.org/en/release-0.4/manual/noteworthy-differences/" rel="noreferrer">this</a> page it says that methods <code>push!()</code> and <code>append!()</code> are very efficient.</p>

<p>My question is how exactly efficient they are?</p>

<p>Namely,</p>

<p>If one <strong>knows</strong> the size of the final array, is it still faster to preallocate the array or growing it incrementally using <code>append!()</code> / <code>push!()</code> would be just as efficient?</p>

<p>Now consider the case when one <strong>does not know</strong> the size of the final array. For example, merging multiple arrays into 1 big array (call it <code>A</code>).</p>

<p>Two ways to achieve this:</p>

<ol>
<li><code>append!()</code>-ing each array to <code>A</code>, whose size has not been preallocated.</li>
<li>First sum dimensions of each array to find the final size of the merged array <code>A</code>. Then preallocate <code>A</code> and copy over contents of each array.</li>
</ol>

<p>Which one would be more efficient in this case?</p>