aboutsummaryrefslogtreecommitdiffstats
path: root/lib/observer/src/etop.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-03-14 14:54:07 +0100
committerBjörn Gustavsson <[email protected]>2013-03-14 14:54:07 +0100
commit2251b9344c2e5d0ba5d43f89a1ad896c1e67cb0c (patch)
tree169caa76a1c314684b699a0eb2cdf7581ce76dc4 /lib/observer/src/etop.erl
parent59ab7fcb61da503f7a25d6d85fa555b4d9be5f8f (diff)
parent5f764a80aab1af1bbae170f8819fe3c3393b0cb6 (diff)
downloadotp-2251b9344c2e5d0ba5d43f89a1ad896c1e67cb0c.tar.gz
otp-2251b9344c2e5d0ba5d43f89a1ad896c1e67cb0c.tar.bz2
otp-2251b9344c2e5d0ba5d43f89a1ad896c1e67cb0c.zip
Merge branch 'maint'
* maint: [sasl] Fix tests that compare execution time Prepare release PER: Ensure that the complete encoding is at least one byte PER/UPER: Correct decoding of ENUMERATEDs with a single value [jinterface] Kill process between tests to avoid consequential error [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 [jinterface] Make tests handle space in path on windows [common_test] Extend timers for slave nodes in ct_cover_SUITE [test_server] Clean up unused code in test_server_SUITE [reltool] Increase timetrap timeout for reltool_server_SUTIE to 10 minutes [test_server] Fix encoding of HTML file references to work on windows [test_server] Use simpler tc name in unicode test to make it work on windows
Diffstat (limited to 'lib/observer/src/etop.erl')
-rw-r--r--lib/observer/src/etop.erl35
1 files changed, 31 insertions, 4 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, []) -> [].