[erlang-questions] clarify: why bit syntax so slow + benchmark code
Fri Nov 16 23:20:15 CET 2007
On Nov 16, 2007, at 4:09 PM, Per Gustafsson wrote:
> It is slow because for each iteration a two sub-binary structure
> (about 5 words) is allocated. This will be optimized in the next
> release of Erlang/OTP, but your code is sub optimal anyway, if you
> want good performance you should write:
> test1(<<>>) -> done;
> test1(<<_A, Rest/binary>>) ->
> That is, you should not first pattern match and create a sub-binary
> and then match against that one.
It was written that way to show that some calculations are done on that
matched value later. Generally speaking
I'm having a trouble parsing a stream of data
where each control frame is single byte and I have no knowledge of
the stream unless I parse that single byte (i.e. and ~3-4 bytes after
it - they vary depending
on that first single byte).
I'm curious, can erlang achieve good performance with that kind of
stream data filtering?
More information about the erlang-questions