[erlang-questions] Parsing binaries performance

Sebastian Dehne <>
Wed Jun 25 17:41:08 CEST 2008


Hello list,

I'm trying to write a parser in Erlang for a byte-stream (which I 
receive from the TCP socket), but I realise that my code is slow 
compared to the java version which I have. I've attached both version.

The java prints version:
Done: 93

The erlang version prints:
$ erl
Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0] 
[kernel-poll:false]

Eshell V5.5.5  (abort with ^G)
1> c(test).
{ok,test}
2> Data1 = <<"Somestringcontainingcrlf\r\nandsomemoretextbehind\r\n">>. 

<<"Somestringcontainingcrlf\r\nandsomemoretextbehind\r\n">>
3>
3> test:testwrapper(Data1, 500000).
Erlang Elapsed 1570 (runtime) 1586 (wall clock) milliseconds
ok

Both tests are run on the same machine. I also run the test several 
times. Quite a difference between 93ms and 1586ms.

What am I doing wrong? How should I write the code in Erlang such that 
it matches the performance of Java?


Thanks

Sebastian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Test.java
Type: text/x-java
Size: 1095 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080625/82b00a7a/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.erl
Type: text/x-erlang
Size: 636 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080625/82b00a7a/attachment-0001.bin>


More information about the erlang-questions mailing list