Colm
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
>
________________________________________________________________
erlang-questions mailing list. See http://www.erlang.org/faq.html
erlang-questions (at) erlang.org
On my laptop:
benchmark:run(1000000).
--<process dictionary>--
set:210(302)ms
get:190(283)ms
--<dict>--
set:59430(62403)ms
get:790(841)ms
--<ets>--
set:1470(1566)ms
get:940(984)ms
--<gb_trees>--
set:10340(11286)ms
get:690(763)ms
Yes, for small objects, dict is slower than ets.
For larger objects, the copying overhead of using ets
will tip the scales in dict's favor* - at least for a non-
shared dictionary. If you need concurrent access to the
dictionary, you need to keep the dict in a separate process,
which will incur the same copying cost as for ets.
* While both solutions use constant-time algorithms,
dict will also suffer from garbage collection overhead,
which is roughly proportional to the size of the live data
set. Ets tables are not garbage collected.
BR,
Ulf W
--
Ulf Wiger
CTO, Erlang Training & Consulting Ltd
http://www.erlang-consulting.com