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

Benoit Chesneau bchesneau@REDACTED
Thu Mar 17 14:45:29 CET 2016


in somewhat related i studied recently the impact of each for a simple
lookup in erlang-idna. The main goal was to find the best write-once
read-only K/V data structure to embed in a beam without the cost of ets or
a gen_server:

https://github.com/benoitc/erlang-idna/issues/12

between pattern matching and maps on a string with 29915 entries maps were
faster and - not sure why - it creates a smaller beam. Maps are also faster
to compile and use less memory in the process.

anyway you should probably test the right one for your case.

- benoît

On Wed, 16 Mar 2016 at 09:05, 饕餮 <249505968@REDACTED> 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
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160317/794e00e9/attachment.htm>


More information about the erlang-questions mailing list