http://docs.julialang.org/en/latest/stdlib/collections/#Base.sizehint!
On Mon, Mar 9, 2015 at 7:34 PM, Dejan Miljkovic <dej...@gmail.com> wrote: > I would like to initialize dictionary (String/String) with 4 million > key/value pairs. Insert performance varies dramatically. Fast first 200k > than slow around 300k. Pickups > at 400k and than slows down ... > This looks like memory allocation problem. I don't see the method where we > can set size of the dictionary in advance. > > Dejan > > f = open(ARGS[1]) > dic = Dict{String, String}() > cnt = 0 > while !eof(f) > cnt += 1 > if cnt%1000 == 0 > println(cnt) > end > line = chomp(readline(f)) > el = split(line, ",") > key = el[1] > val = el[2] > dic[key] = val > end > close(f) >