[erlang-questions] Hipe and Binary - Bitstring

Oliver Bollmann oliver.bollmann@REDACTED
Wed Mar 27 10:09:35 CET 2019


I use, with binaries like <<1:1000000>>,

one(F,<<Size:64/unsigned,Bitmap:Size/bitstring,_/bitstring>>) ->
   one(F,Bitmap,0,[]). one(F, <<0:1,R/bitstring>>,N,Acc) ->
   one(F,R,N +1,Acc);
one(F, <<1:1,R/bitstring>>,N,Acc) ->
   one(F,R,N +1, [F(N) |Acc]);
one(_, <<>>,_,Acc) ->Acc. union(<<Size:64/unsigned,L:Size/unsigned,P/bitstring>>,
     <<Size:64/unsigned,R:Size/unsigned,_/bitstring>>) ->
   <<Size:64/unsigned, (L bor R):Size/unsigned,P/bitstring>>.

and call this functions 1,000,000 times, this takes for 1,000 calls 
about 20 minutes,

if i compile with native -compile([native,{hipe, o2}])it takes 3 seconds 
for 1,000 calls, so it is about 400x faster !!

OS: OSX

What is the secret?

-- 
Grüße
Oliver Bollmann

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190327/f944ff92/attachment.htm>


More information about the erlang-questions mailing list