[erlang-questions] Parsing binaries performance

Lev Walkin <>
Wed Jun 25 18:16:01 CEST 2008


Sebastian Dehne wrote:
> 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.

Yes, Erlang is slow doing that. Try running 30000 processes in parallel
in Java and measure the difference that way. You'll find yourself
writing into some Java mailing list asking for a way to make Java
code match Erlang performance.

Meanwhile, try using +native mode if you have HiPE enabled
on your platform. This might help a bit.

> 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
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list