about erlang eprof tool. Why is the handle_info and handle_cast without in the result

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

about erlang eprof tool. Why is the handle_info and handle_cast without in the result

jasonlxw
hi everybody:
I write a test 'chat' code with eprof.
I have found the handle_info and handle_cast functions without in the anaylise result.
Why ?

thanks 
Regards
jason

  1 -module(chat).                                                                                                                                           
  2 -compile(export_all).
  3 %-behaviour(gen_server).
  4 start(N) ->
  5     start_link(), 
  6     eprof:start(),
  7     eprof:start_profiling([chat]),
  8     test(N),
  9     testcast(),
 10     test(),
 11     eprof:stop_profiling(),
 12     eprof:log(chat),
 13     eprof:analyse(),
 14     eprof:total_analyse().  
 15 
 16 test(N)->
 17     gen_server:call(?MODULE, {test,N}).
 18 test()->
 19     chat ! {test,1}.
 20 testcast() ->
 21     gen_server:cast(?MODULE,castttt).
 22 
 23 start_link() ->
 24     gen_server:start_link({local,?MODULE},?MODULE,[],[]).
 25 
 26 init([]) ->
 27     {ok, {}}.
 28 
 29 handle_cast(Msg,State) ->
 30     tttt(), 
 31     io:format("cast=~p~n",[Msg]),
 32     {noreply,State}.
 33 
 34 handle_call({test,Number},From, State) when is_number(Number) ->
 35     Reply = Number+1,
 36     {reply, Reply,State};
 37 
 38 handle_call(_,From, State) ->
 39     Reply = numerror,
 40     {reply, Reply,State}.
 41 handle_info(Ino,State) ->
 42     tttt(), 
 43     io:format("info=~p~n",[Ino]),
 44     {noreply,State}.
 45 tttt() ->
 46     ok.
%%%%%%%%%%%%%%%%%
Test result
5> chat:start(1).
eprof: Starting profiling ..... 
eprof: Stop profiling
cast=castttt
info={test,1}
FUNCTION                                       CALLS      TIME 

****** Process <0.35.0>    -- 100 % of profiled time *** 
gen_server:loop/6                               1          30 % 
gen_server:handle_msg/5                   1          28 % 
chat:handle_call/3                              1          21 % 
gen_server:reply/2                             1          14 % 
gen_server:decode_msg/8                  1          8 % 

Total time: 0.00
Measurement overhead: 0.00
FUNCTION                                       CALLS      TIME 
gen_server:loop/6                                1          30 % 
gen_server:handle_msg/5                     1          28 % 
chat:handle_call/3                                1          21 % 
gen_server:reply/2                               1          14 % 
gen_server:decode_msg/8                    1          8 % 

Total time: 0.00
Measurement overhead: 0.00
ok
6> 


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

chat.erl (1K) Download Attachment
Never give up
Reply | Threaded
Open this post in threaded view
|

Re: about erlang eprof tool. Why is the handle_info and handle_cast without in the result

Ahmed Omar
Sending a message (handled by handle_info) or doing a cast (handled by handle_cast) are both async.
You are stopping the profiler too early.
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

On Wed, May 18, 2011 at 10:57 AM, 郎咸武 <[hidden email]> wrote:
hi everybody:
I write a test 'chat' code with eprof.
I have found the handle_info and handle_cast functions without in the anaylise result.
Why ?

thanks 
Regards
jason

  1 -module(chat).                                                                                                                                           
  2 -compile(export_all).
  3 %-behaviour(gen_server).
  4 start(N) ->
  5     start_link(), 
  6     eprof:start(),
  7     eprof:start_profiling([chat]),
  8     test(N),
  9     testcast(),
 10     test(),
 11     eprof:stop_profiling(),
 12     eprof:log(chat),
 13     eprof:analyse(),
 14     eprof:total_analyse().  
 15 
 16 test(N)->
 17     gen_server:call(?MODULE, {test,N}).
 18 test()->
 19     chat ! {test,1}.
 20 testcast() ->
 21     gen_server:cast(?MODULE,castttt).
 22 
 23 start_link() ->
 24     gen_server:start_link({local,?MODULE},?MODULE,[],[]).
 25 
 26 init([]) ->
 27     {ok, {}}.
 28 
 29 handle_cast(Msg,State) ->
 30     tttt(), 
 31     io:format("cast=~p~n",[Msg]),
 32     {noreply,State}.
 33 
 34 handle_call({test,Number},From, State) when is_number(Number) ->
 35     Reply = Number+1,
 36     {reply, Reply,State};
 37 
 38 handle_call(_,From, State) ->
 39     Reply = numerror,
 40     {reply, Reply,State}.
 41 handle_info(Ino,State) ->
 42     tttt(), 
 43     io:format("info=~p~n",[Ino]),
 44     {noreply,State}.
 45 tttt() ->
 46     ok.
%%%%%%%%%%%%%%%%%
Test result
5> chat:start(1).
eprof: Starting profiling ..... 
eprof: Stop profiling
cast=castttt
info={test,1}
FUNCTION                                       CALLS      TIME 

****** Process <0.35.0>    -- 100 % of profiled time *** 
gen_server:loop/6                               1          30 % 
gen_server:handle_msg/5                   1          28 % 
chat:handle_call/3                              1          21 % 
gen_server:reply/2                             1          14 % 
gen_server:decode_msg/8                  1          8 % 

Total time: 0.00
Measurement overhead: 0.00
FUNCTION                                       CALLS      TIME 
gen_server:loop/6                                1          30 % 
gen_server:handle_msg/5                     1          28 % 
chat:handle_call/3                                1          21 % 
gen_server:reply/2                               1          14 % 
gen_server:decode_msg/8                    1          8 % 

Total time: 0.00
Measurement overhead: 0.00
ok
6> 


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions




--
Best Regards,
- Ahmed Omar
Follow me on twitter


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: about erlang eprof tool. Why is the handle_info and handle_cast without in the result

jasonlxw
I try  to do after adding seelp.
It is ok .
You are right.
Thank you,

2011/5/18 Ahmed Omar [via Erlang] <[hidden email]>
Sending a message (handled by handle_info) or doing a cast (handled by handle_cast) are both async.
You are stopping the profiler too early.
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

On Wed, May 18, 2011 at 10:57 AM, 郎咸武 <[hidden email]> wrote:
hi everybody:
I write a test 'chat' code with eprof.
I have found the handle_info and handle_cast functions without in the anaylise result.
Why ?

thanks 
Regards
jason

  1 -module(chat).                                                                                                                                           
  2 -compile(export_all).
  3 %-behaviour(gen_server).
  4 start(N) ->
  5     start_link(), 
  6     eprof:start(),
  7     eprof:start_profiling([chat]),
  8     test(N),
  9     testcast(),
 10     test(),
 11     eprof:stop_profiling(),
 12     eprof:log(chat),
 13     eprof:analyse(),
 14     eprof:total_analyse().  
 15 
 16 test(N)->
 17     gen_server:call(?MODULE, {test,N}).
 18 test()->
 19     chat ! {test,1}.
 20 testcast() ->
 21     gen_server:cast(?MODULE,castttt).
 22 
 23 start_link() ->
 24     gen_server:start_link({local,?MODULE},?MODULE,[],[]).
 25 
 26 init([]) ->
 27     {ok, {}}.
 28 
 29 handle_cast(Msg,State) ->
 30     tttt(), 
 31     io:format("cast=~p~n",[Msg]),
 32     {noreply,State}.
 33 
 34 handle_call({test,Number},From, State) when is_number(Number) ->
 35     Reply = Number+1,
 36     {reply, Reply,State};
 37 
 38 handle_call(_,From, State) ->
 39     Reply = numerror,
 40     {reply, Reply,State}.
 41 handle_info(Ino,State) ->
 42     tttt(), 
 43     io:format("info=~p~n",[Ino]),
 44     {noreply,State}.
 45 tttt() ->
 46     ok.
%%%%%%%%%%%%%%%%%
Test result
5> chat:start(1).
eprof: Starting profiling ..... 
eprof: Stop profiling
cast=castttt
info={test,1}
FUNCTION                                       CALLS      TIME 

****** Process <0.35.0>    -- 100 % of profiled time *** 
gen_server:loop/6                               1          30 % 
gen_server:handle_msg/5                   1          28 % 
chat:handle_call/3                              1          21 % 
gen_server:reply/2                             1          14 % 
gen_server:decode_msg/8                  1          8 % 

Total time: 0.00
Measurement overhead: 0.00
FUNCTION                                       CALLS      TIME 
gen_server:loop/6                                1          30 % 
gen_server:handle_msg/5                     1          28 % 
chat:handle_call/3                                1          21 % 
gen_server:reply/2                               1          14 % 
gen_server:decode_msg/8                    1          8 % 

Total time: 0.00
Measurement overhead: 0.00
ok
6> 


_______________________________________________
erlang-questions mailing list
[hidden email]



--
Best Regards,
- Ahmed Omar
Follow me on twitter


_______________________________________________
erlang-questions mailing list
[hidden email]

To start a new topic under Erlang Questions, email [hidden email]
To unsubscribe from Erlang Questions, click here.

Never give up