<div><div><div><div>dict write x 10000 </div><div><br></div><div>> {T,D} = timer:tc(test,dict_read,[]).</div><div>{86177,...</div></div><div><br></div><div>dict read x 10000 </div><div>> timer:tc(test,dict_read,[D]).</div>
<div>{17260,</div><div><br></div><div>-----------------------------</div></div><div><br></div><div>ets write x 10000 </div><div>> {T,E}=timer:tc(test,ets_write,[]).</div><div>{18005,20493}</div><div><br></div><div>dict read x 10000 </div>
<div>> timer:tc(test,ets_read,[E]). </div><div>{15706,</div><div><br></div><div><br></div><div>test.erl</div><div>---------- 8< ------------------</div></div><div><br></div><div>-module(test).</div><div>-export([dict_write/0,dict_read/1,ets_write/0,ets_read/1]).</div>
<div><br></div><div>dict_write()-></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>D = dict:new(),</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>dict_write(D,10000).</div>
<div><br></div><div>dict_write(D,0)->D;</div><div>dict_write(D,N)->dict_write(dict:store(N,N,D),N-1).</div><div><br></div><div>dict_read(D)-></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>[ dict:find(X,D) || X<-lists:seq(0,10000) ].</div>
<div><br></div><div>ets_write()-></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>E = ets:new(test,[set]),</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>[ ets:insert(E,{X,X}) || X<-lists:seq(0,10000) ],</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>E.</div><div><br></div><div>ets_read(E)-></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>[ ets:lookup(E,X) || X<-lists:seq(0,10000) ].</div>
<div><br></div>