[erlang-questions] which one is more efficiency? ets or pattern match?

Hynek Vychodil <>
Wed Mar 16 10:05:33 CET 2016


If your key is numbers and mostly continuous sequence element(X, {11, 22,
..., 12312}) is the most efficient solution. Use X+K for more different
values. When your keys are general terms, try use maps:get/2,3. It is
important to have the map or the tuple as literal constant in the module.
(Then it's shared between processes.) Always try and measure for your use
pattern.

On Wed, Mar 16, 2016 at 9:05 AM, 饕餮 <> wrote:

> erlang pattern match file could be written like :
>
> -module(config).
> get(1) -> 11,
> get(2) -> 22,
> .....
> get(1000001) -> 12312,
> get(_) -> none.
>
> When I need get some data,
> ets:lookup(some_table, some_value)
> &
> config:get(some_value)
>
> Which one is more efficiency?
> How much different between them?
>
>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160316/f32af920/attachment.html>


More information about the erlang-questions mailing list