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

Vance Shipley vances@REDACTED
Wed Mar 16 12:58:07 CET 2016


On Wed, Mar 16, 2016 at 5:07 PM, 饕餮 <249505968@REDACTED> 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



More information about the erlang-questions mailing list