[erlang-questions] which one is more efficiency? ets or pattern match?
Wed Mar 16 10:38:12 CET 2016
Your example suggests that the keys are strictly from 1..N
If this is the case then the array module *should be* the most efficient.
If the array module is not the most efficient and it turned out that
(say ets) is more
efficient then parts of the array module should be rewritten using ets
to reflect this.
My point here is not only should you ask what is the most efficient
way to do X, but
that the solution should be in the place where you expect to find it.
If the array indices are in gappy integer sequences then you should use
sparce_arrays.erl - but this hasn't been written, so go write it :-)
If the array indices are unpredictable use maps or ets - you'd have to
measure to find the best
On Wed, Mar 16, 2016 at 9:05 AM, 饕餮 <249505968@REDACTED> wrote:
> erlang pattern match file could be written like :
> get(1) -> 11,
> get(2) -> 22,
> get(1000001) -> 12312,
> get(_) -> none.
> When I need get some data,
> ets:lookup(some_table, some_value)
> Which one is more efficiency?
> How much different between them?
> erlang-questions mailing list
More information about the erlang-questions