[erlang-questions] Hipe and Binary - Bitstring

John Högberg john@REDACTED
Wed Mar 27 13:04:56 CET 2019


Hi Oliver,
I've tried to reproduce this discrepancy on my machine, but I can only
see a modest difference on latest OTP 21 (the results are in
microseconds):
Erlang/OTP 21 [erts-10.3.1] [source] [64-bit] [smp:24:24] [ds:24:24:10]
[async-threads:1] [hipe]
Eshell V10.3.1  (abort with ^G)1> c(t, []).           {ok,t}2>
t:bench(one).       159573043> t:bench(union).5594704> c(t,
[native]).     {ok,t}5> t:bench(one).  36113716> t:bench(union).501871
I've attached the source code I used for this test, am I missing
something?
Regards,John Högberg
On Wed, 2019-03-27 at 10:09 +0100, Oliver Bollmann wrote:
>     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üßeOliver Bollmann
>   
> 
> _______________________________________________erlang-questions
> mailing listerlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190327/51c0b665/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.erl
Type: text/x-erlang
Size: 1090 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190327/51c0b665/attachment.bin>


More information about the erlang-questions mailing list