diff options
author | Siri Hansen <[email protected]> | 2013-03-14 11:06:27 +0100 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2013-03-14 11:06:27 +0100 |
commit | 8e44167cb97ccf51a8ee3ca97449613ef3300514 (patch) | |
tree | 7e4dcabf0b3a431a9fd05c48d3f35285095195f9 /lib/observer/src | |
parent | e2ee1f79a7d0ffe02eab4da90d655e77893d1666 (diff) | |
parent | 6ab4b1c2a7a5a89dd8ea4094bd7fb4c23745acfc (diff) | |
download | otp-8e44167cb97ccf51a8ee3ca97449613ef3300514.tar.gz otp-8e44167cb97ccf51a8ee3ca97449613ef3300514.tar.bz2 otp-8e44167cb97ccf51a8ee3ca97449613ef3300514.zip |
Merge branch 'siri/observer/misc-bugs/OTP-10894' into maint
* siri/observer/misc-bugs/OTP-10894:
[observer] Extend timer to allow trace msgs to arrive over tcp/ip
[observer] Kill slave node between tests in etop_SUITE
[observer] Accept current function for a process to be 'undefined' on hipe
[observer] Improve measurement of CPU utilization in etop
[observer] Fix non tail-recusive loop when measuring scheduler utilization
Diffstat (limited to 'lib/observer/src')
-rw-r--r-- | lib/observer/src/etop.erl | 35 | ||||
-rw-r--r-- | lib/observer/src/etop_gui.erl | 9 |
2 files changed, 38 insertions, 6 deletions
diff --git a/lib/observer/src/etop.erl b/lib/observer/src/etop.erl index 428757e5ce..2610060eae 100644 --- a/lib/observer/src/etop.erl +++ b/lib/observer/src/etop.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2002-2012. All Rights Reserved. +%% Copyright Ericsson AB 2002-2013. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -325,13 +325,40 @@ loadinfo(SysI) -> #etop_info{n_procs = Procs, run_queue = RQ, now = Now, - wall_clock = {_, WC}, - runtime = {_, RT}} = SysI, - Cpu = round(100*RT/WC), + wall_clock = WC, + runtime = RT} = SysI, + Cpu = calculate_cpu_utilization(WC,RT), Clock = io_lib:format("~2.2.0w:~2.2.0w:~2.2.0w", tuple_to_list(element(2,calendar:now_to_datetime(Now)))), {Cpu,Procs,RQ,Clock}. +calculate_cpu_utilization({_,WC},{_,RT}) -> + %% Old version of observer_backend, using statistics(wall_clock) + %% and statistics(runtime) + case {WC,RT} of + {0,0} -> + 0; + {0,_} -> + 100; + _ -> + round(100*RT/WC) + end; +calculate_cpu_utilization(_,undefined) -> + %% First time collecting - no cpu utilization has been measured + %% since scheduler_wall_time flag is not yet on + 0; +calculate_cpu_utilization(_,RTInfo) -> + %% New version of observer_backend, using statistics(scheduler_wall_time) + Sum = lists:foldl(fun({_,A,T},{AAcc,TAcc}) -> {A+AAcc,T+TAcc} end, + {0,0}, + RTInfo), + case Sum of + {0,0} -> + 0; + {Active,Total} -> + round(100*Active/Total) + end. + meminfo(MemI, [Tag|Tags]) -> [round(get_mem(Tag, MemI)/1024)|meminfo(MemI, Tags)]; meminfo(_MemI, []) -> []. diff --git a/lib/observer/src/etop_gui.erl b/lib/observer/src/etop_gui.erl index f5cc0deb38..3971646abc 100644 --- a/lib/observer/src/etop_gui.erl +++ b/lib/observer/src/etop_gui.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2002-2012. All Rights Reserved. +%% Copyright Ericsson AB 2002-2013. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -276,7 +276,12 @@ clear_lines(From, To, Grid) -> end. formatmfa({M, F, A}) -> - io_lib:format("~w:~w/~w",[M, F, A]). + io_lib:format("~w:~w/~w",[M, F, A]); +formatmfa(Other) -> + %% E.g. when running hipe - the current_function for some + %% processes will be 'undefined' + io_lib:format("~w",[Other]). + makegridlines([#etop_proc_info{pid=Pid, mem=Mem, |