Yeah, that makes it even more clear that they’re very similar:

julia> gc(); @time for i=1:1_000; sizehint!(Vector{Int}(0), 1_000); end
  0.000186 seconds (2.00 k allocations: 7.721 MB)

julia> gc(); @time for i=1:1_000; Vector{Int}(1_000); end
  0.000181 seconds (1000 allocations: 7.706 MB)

(broken into smaller chunks, because the timings started to get awfully 
close to the resolution of the clock, and the gc percentage count got 
really borked…)

// T

On Monday, November 16, 2015 at 6:26:04 PM UTC+1, Steven G. Johnson wrote:


>
> On Monday, November 16, 2015 at 11:24:20 AM UTC-5, Tomas Lycken wrote:
>>
>> Making sure that precompilation and gc don’t factor into the result, I 
>> get quite different timings:
>>
>> julia> gc(); @time sizehint!(a, 10_000_000);
>>   0.001493 seconds (46 allocations: 76.296 MB, 304.61% gc time)
>>
>> julia> gc(); @time b = zeros(Int, 10_000_000);
>>   0.021997 seconds (38 allocations: 76.296 MB, 0.70% gc time)
>>
>>
> Compare to Array(Int,  10_000_000), which allocates an uninitialized array.
>
>> ​
>>>>
>>> ​
>>
> ​

Reply via email to