Slow UTP packets
Ovidiu Deac
ovidiudeac@REDACTED
Thu Jul 30 14:29:43 CEST 2009
Hi everybody,
I want to do some speed tests for parsing packets and I wrote a small
program which receives data on a multicast address and writes it to a
file. While this application is running I measure the growing speed of
the output file to get an idea about the speed.
The problem is that the output speed is getting slower as the
application runs. Initially the output file grows with about 1MB/s
then it slows down to 700KB/s 500Kb/s... and so on until it reaches
1KB/s. Any idea why?
I know that the data is sent to the multicast address with 1MB/s and
also I have a python version which writes to the file with the
constant speed of 1MB/s. So there has to be something wrong with my
erlang program.
Note that it's basically my first erlang application so I might done
something really stupid.
I'm using Erlang R13B01 (erts-5.7.2) [source] [smp:2:2] [rq:2]
[async-threads:0] [hipe] [kernel-poll:false]
I have this problem both with and without hipe compilation.
See the code below.
Thanks in advance,
ovidiu
-module(unpacker).
-export([start/3]).
start(OutputFile, Ip, Port) ->
{ok, Socket} = gen_udp:open(Port, [binary, {active, true},
{reuseaddr, true},{ip, Ip},
{add_membership, {Ip, {0,0,0,0}}}]),
{ok, File} = file:open(OutputFile, write),
parseNextPacket(Socket,
File).
parseNextPacket(Socket, File) ->
receive
{udp, Socket, _Host, _Port, Data}->
io:format(File, "Packet: ~p", [Data]),
parseNextPacket(Socket, File);
Any ->
io:format("Unknown message: ~p~n", [Any]),
io:format(File, "Unknown message: ~p", [Any]),
parseNextPacket(Socket, File)
end.
More information about the erlang-questions
mailing list