[erlang-questions] performance vs msg queue length
Per Melin
per.melin@REDACTED
Tue Apr 20 21:15:12 CEST 2010
On Tue, Apr 20, 2010 at 8:41 PM, John Erickson <jderick@REDACTED> wrote:
> [begin [ self() ! a || _ <- lists:seq(1,N) ],
>> S = now(),
>> [ receive _ -> ok end || _ <- lists:seq(1,N) ],
>> io:format("~w~n", [timer:now_diff(now(), S) / N])
>> end || N <- [1,10,100,1000,10000]].
>>
>> ...
>>
>> If I put it into a module, add 1e5 and 1e6 then I get:
>>
>> 1> test:test().
>> 1.0
>> 0.1
>> 0.06
>> 0.114
>> 0.1554
>> 0.36398
>> 0.358997
One little change:
[begin L = lists:seq(1,N),
[ self() ! a || _ <- L ],
S = now(),
[ receive _ -> ok end || _ <- L ],
io:format("~w~n", [timer:now_diff(now(), S) / N])
end || N <- [1,10,100,1000,10000,100000,1000000]].
1.0
0.1
0.06
0.091
0.1144
0.11898
0.120905
More information about the erlang-questions
mailing list