reductions galore

Anthony Shipman als@REDACTED
Wed Feb 24 11:45:01 CET 2010

Here is some code from experimenting with profiling.

run() ->
    Keys = lists:seq(1, 2000),

    Child = spawn(fun() -> receive after 5000 -> ok end end),
    %Child = spawn(fun() -> receive _ -> ok end end),

    {reductions,R1} = process_info(self(), reductions),
    lists:foreach(fun(K) -> Child!K end, Keys),
    {reductions,R2} = process_info(self(), reductions),

    io:format("reductions ~p~n", [R2 - R1]),

It prints
	reductions 3344538

If I change the child process to the second one with the receive X I get
	reductions 6334

In the first case messages are queuing in the child process. But can the 
reduction count be real?

Anthony Shipman                    Mamas don't let your babies 
als@REDACTED                   grow up to be outsourced.

More information about the erlang-questions mailing list