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

Jesper Louis Andersen <>
Wed Mar 16 13:32:54 CET 2016


It is pretty good for lookup tables. Another such implementation:

https://github.com/jlouis/eministat/blob/master/src/eministat_analysis.erl#L85-L190

On Wed, Mar 16, 2016 at 1:16 PM, Dan Gudmundsson <> wrote:

> You can build large tuples and use element/2 on them as well, for example
> see functions in the bottom of rand.erl.
>
> On Wed, Mar 16, 2016 at 12:58 PM Vance Shipley <> wrote:
>
>> On Wed, Mar 16, 2016 at 5:07 PM, 饕餮 <> wrote:
>> > But someone is afraid about the efficiency of pattern match.(because we
>> are
>> > not very sure about the efficiency of pattern match,just heard that if
>> the
>> > code is good, it will be a binary search).
>>
>> Pattern matching is quite efficient up to some point of design intent.
>> Some guidance is in the Efficiency Guide here:
>> http://erlang.org/doc/efficiency_guide/functions.html#id68205
>>
>> What you need to worry about however is in how many clauses heads you
>> have.  I once benchmarked this and found that it worked well up to
>> something on the order of thousands but wouldn't compile beyond that.
>> This is the sort of thing which could change for the better or worse
>> with any Erlang release because they've never expressed a guarantee.
>> I haven't tried it lately.
>>
>>
>>
>> --
>>      -Vance
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
>


-- 
J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160316/f4495f02/attachment.html>


More information about the erlang-questions mailing list