[erlang-questions] [eeps] EEP 9

Jay Nelson jay@REDACTED
Sun Mar 9 18:53:00 CET 2008


 > In addition I would like to add functions to transform and filter
 > binaries in a more efficient fashion than can be done by binary
 > comprehensions, e.g. by a lookup table as suggested by Jay here:
 > http://www.duomark.com/erlang/publications/acm2005.pdf (chapter  
4.1 is
 > especially interesting). This would mean some new built-in functions,
 > binary:translate, binary:extract and possibly some more.

Just a caveat that I did these comparisons on R10B-5 and I have not  
yet had a chance to rerun using R12B-1.  The main speed up in  
stream_xlate was the elimination of excess memory allocation by pre- 
allocating the result binary and filling it in place, although the  
fast table lookup also helped.

My understanding of how R12B binaries works using binary  
comprehensions indicates that you may approach the speed of the BIF  
now with a direct erlang expression, but I would still expect the BIF  
to be 2-4x faster (rather than 70-200x, just a random guess on my part):

XlatedBinary = << if B >= $A andalso B =< $Z -> B - $A + $a; true ->  
B end  ||  B <= RawBinary>>.

I'm not sure how the result is allocated if there are any filter  
clauses, I just assume without filter clauses the entire binary size  
can be pre-computed and pre-allocated.

jay




More information about the erlang-questions mailing list