Sending a message (handled by handle_info) or doing a cast (handled by handle_cast) are both async.<div>You are stopping the profiler too early.</div><div>Changing the order to do the async operations first, then the sync one should assure that all the requests have been handled before you stop eprof<br>
<br><div class="gmail_quote">On Wed, May 18, 2011 at 10:57 AM, 郎咸武 <span dir="ltr"><<a href="mailto:langxianzhe@gmail.com">langxianzhe@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div>hi everybody:</div><div>I write a test 'chat' code with eprof.</div><div>I have found the handle_info and handle_cast functions without in the anaylise result.</div><div>Why ?</div><div><br></div><div>thanks </div>
<div>Regards</div><div>jason</div><div><br></div><div><div> 1 -module(chat). </div>
<div> 2 -compile(export_all).</div><div> 3 %-behaviour(gen_server).</div><div> 4 start(N) -></div><div> 5 start_link(), </div><div> 6 eprof:start(),</div><div> 7 eprof:start_profiling([chat]),</div><div>
8 test(N),</div><div> 9 testcast(),</div><div> 10 test(),</div><div> 11 eprof:stop_profiling(),</div><div> 12 eprof:log(chat),</div><div> 13 eprof:analyse(),</div><div> 14 eprof:total_analyse(). </div>
<div> 15 </div><div> 16 test(N)-></div><div> 17 gen_server:call(?MODULE, {test,N}).</div><div> 18 test()-></div><div> 19 chat ! {test,1}.</div><div> 20 testcast() -></div><div> 21 gen_server:cast(?MODULE,castttt).</div>
<div> 22 </div><div> 23 start_link() -></div><div> 24 gen_server:start_link({local,?MODULE},?MODULE,[],[]).</div><div> 25 </div><div> 26 init([]) -></div><div> 27 {ok, {}}.</div><div> 28 </div><div> 29 handle_cast(Msg,State) -></div>
<div> 30 tttt(), </div><div> 31 io:format("cast=~p~n",[Msg]),</div><div> 32 {noreply,State}.</div><div> 33 </div><div> 34 handle_call({test,Number},From, State) when is_number(Number) -></div><div>
35 Reply = Number+1,</div><div> 36 {reply, Reply,State};</div></div><div><div> 37 </div><div> 38 handle_call(_,From, State) -></div><div> 39 Reply = numerror,</div><div> 40 {reply, Reply,State}.</div>
<div>
41 handle_info(Ino,State) -></div><div> 42 tttt(), </div><div> 43 io:format("info=~p~n",[Ino]),</div><div> 44 {noreply,State}.</div><div> 45 tttt() -></div><div> 46 ok.</div></div><div>%%%%%%%%%%%%%%%%%</div>
<div>Test result</div><div><div>5> chat:start(1).</div><div>eprof: Starting profiling ..... </div><div>eprof: Stop profiling</div><div>cast=castttt</div><div>info={test,1}</div><div>FUNCTION CALLS TIME </div>
<div><br></div><div>****** Process <0.35.0> -- 100 % of profiled time *** </div><div>gen_server:loop/6 1 30 % </div><div>gen_server:handle_msg/5 1 28 % </div>
<div>chat:handle_call/3 1 21 % </div><div>gen_server:reply/2 1 14 % </div><div>gen_server:decode_msg/8 1 8 % </div><div>
<br></div><div>Total time: 0.00</div><div>Measurement overhead: 0.00</div><div>FUNCTION CALLS TIME </div><div>gen_server:loop/6 1 30 % </div>
<div>gen_server:handle_msg/5 1 28 % </div><div>chat:handle_call/3 1 21 % </div><div>gen_server:reply/2 1 14 % </div>
<div>gen_server:decode_msg/8 1 8 % </div><div><br></div><div>Total time: 0.00</div><div>Measurement overhead: 0.00</div><div>ok</div><div>6> </div></div><div><br></div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Best Regards,<br>- Ahmed Omar<div><a href="http://nl.linkedin.com/in/adiaa" target="_blank">http://nl.linkedin.com/in/adiaa</a></div><div>Follow me on twitter</div><div>
<a href="http://twitter.com/#!/spawn_think" target="_blank">@spawn_think</a></div><br>
</div>