<div dir="ltr">Large maps are currently not optimized, that part is not implemented yet,<div>you should currently only use them for less than 100 keys...</div><div><br></div><div>It is on the todo list..</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Thu, Feb 6, 2014 at 10:28 PM, McDowell, Edward D. <span dir="ltr"><<a href="mailto:EMcDowell@ric.edu" target="_blank">EMcDowell@ric.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal">maps:put/3 in R17rc1 on Windows (64 bit) runs slowly when a<u></u><u></u></p><p class="MsoNormal">large number of randomly generated keys are inserted into a<u></u><u></u></p>
<p class="MsoNormal">map. The following table shows that the time to insert n<u></u><u></u></p><p class="MsoNormal">keys grows quadratically, so the time to insert a single key<u></u><u></u></p><p class="MsoNormal">grows linearly. Note that performance is greatly improved<u></u><u></u></p>
<p class="MsoNormal">by using a dict (from stdlib).<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Number Insert into map Insert into dict<u></u><u></u></p><p class="MsoNormal">of keys (milliseconds) (milliseconds) <u></u><u></u></p>
<p class="MsoNormal">10000 969 16<u></u><u></u></p><p class="MsoNormal">20000 4031 62<u></u><u></u></p><p class="MsoNormal">40000 15937 172<u></u><u></u></p>
<p class="MsoNormal">80000 63734 453<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">The following code was used for these tests. The dict<u></u><u></u></p><p class="MsoNormal">
tests used the same code with dict:new/0 and dict:store/3<u></u><u></u></p><p class="MsoNormal">replacing maps:new/0 and maps:put/3, respectively.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">
-module(testmap).<u></u><u></u></p><p class="MsoNormal">-export([start/1]).<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">loop(Map, 0) -> Map;<u></u><u></u></p><p class="MsoNormal">loop(Map, Times) -><u></u><u></u></p>
<p class="MsoNormal"> Key = random:uniform(999999),<u></u><u></u></p><p class="MsoNormal"> loop(maps:put(Key, true, Map), Times - 1).<u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal">
start(NumKeys) -><u></u><u></u></p><p class="MsoNormal"> {A, B, C} = now(),<u></u><u></u></p><p class="MsoNormal"> random:seed(A, B, C),<u></u><u></u></p><p class="MsoNormal"> Before = (1000000 * A + B) * 1000 + C div 1000,<u></u><u></u></p>
<p class="MsoNormal"> loop(maps:new(), NumKeys),<u></u><u></u></p><p class="MsoNormal"> {E, F, G} = now(),<u></u><u></u></p><p class="MsoNormal"> After = (1000000 * E + F) * 1000 + G div 1000,<u></u><u></u></p><p class="MsoNormal">
io:format("Elapsed time: ~w milliseconds.~n",<u></u><u></u></p><p class="MsoNormal"> [After - Before]).<u></u><u></u></p></div></div><br>_______________________________________________<br>
erlang-bugs mailing list<br>
<a href="mailto:erlang-bugs@erlang.org">erlang-bugs@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-bugs" target="_blank">http://erlang.org/mailman/listinfo/erlang-bugs</a><br>
<br></blockquote></div><br></div>