Other Day @fdmananatold me that he discover that lists key find was much more fast then proplists. Since i use a lot of proplists on my code, i did some tests to check how much fast it is and i was shocked!
(af83@dakua.local)34> timer:tc(proplists,get_value,[99999,List]).
{8685,99999}
(af83@dakua.local)35> timer:tc(lists,keyfind,[99999,1,List]).
{829,{99999,99999}}
WOW! for a list of 100.000 elements proplists:get_value can be 10x slower then lists:key_find!
So now i’m using this encapsulation in order to maintain proplists syntax and avoid extra typing
proplist_get_value(Key,List)->
case lists:keyfind(Key,1,List) of
{_K,V}->
V;
false->
undefined
end.
Now the question is Why? why lists is much more faste then proplists? Our guess is that since lists functions are BIF’s, they must be build in C and proplists no, but this is just a guess, if someone has a better explanation please share.



