aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/observer/src/observer_perf_wx.erl36
-rw-r--r--lib/runtime_tools/src/observer_backend.erl20
2 files changed, 22 insertions, 34 deletions
diff --git a/lib/observer/src/observer_perf_wx.erl b/lib/observer/src/observer_perf_wx.erl
index 0d18112085..48ae74cce1 100644
--- a/lib/observer/src/observer_perf_wx.erl
+++ b/lib/observer/src/observer_perf_wx.erl
@@ -23,16 +23,10 @@
-export([init/1, handle_info/2, terminate/2, code_change/3, handle_call/3,
handle_event/2, handle_sync_event/3, handle_cast/2]).
--export([fetch_stats/2]).
-
--compile(export_all).
-
-behaviour(wx_object).
-include_lib("wx/include/wx.hrl").
-include("observer_defs.hrl").
-%%-compile(export_all).
-
-record(state,
{
offset = 0.0,
@@ -163,7 +157,7 @@ handle_info({active, Node}, State = #state{parent=Parent, appmon=Old}) ->
catch _:_ ->
catch Old ! exit,
Me = self(),
- Pid = spawn_link(Node, ?MODULE, fetch_stats, [Me, 1000]),
+ Pid = spawn_link(Node, observer_backend, fetch_stats, [Me, 1000]),
{noreply, State#state{active=true, appmon=Pid, data={0, queue:new()}}}
end;
@@ -190,24 +184,6 @@ add_data(Stats, {N, Q}) when N > 60 ->
add_data(Stats, {N, Q}) ->
{N+1, queue:in(Stats, Q)}.
-fetch_stats(Parent, Time) ->
- erlang:system_flag(scheduler_wall_time, true),
- fetch_stats_loop(Parent, Time),
- erlang:system_flag(scheduler_wall_time, false).
-
-fetch_stats_loop(Parent, Time) ->
- receive
- exit -> normal
- after Time ->
- _M = Parent ! {stats, 1,
- erlang:statistics(scheduler_wall_time),
- erlang:statistics(io),
- erlang:memory()},
- %% io:format("IO ~p~n",[element(4,_M)]),
- fetch_stats(Parent, Time)
- end.
-
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
create_menus(Parent, _) ->
@@ -263,7 +239,8 @@ calc_delta([], []) -> [].
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
draw(Offset, Id, DC, Panel, Paint=#paint{pens=Pens}, Data) ->
- {Len, Max, Hs} = collect_data(Id, Data),
+ {Len, Max0, Hs} = collect_data(Id, Data),
+ Max = calc_max(Max0),
NoGraphs = try tuple_size(hd(Hs)) catch _:_ -> 0 end,
Size = wxWindow:getClientSize(Panel),
{X0,Y0,WS,HS} = draw_borders(Id, NoGraphs, DC, Size, Max, Paint),
@@ -326,7 +303,6 @@ splines(N, XD, XD0, Tan, Y1,Y2, PX0, Clip={Cx,Cy},ZeroY, WS, Acc) when N > 0 ->
splines(N-1, Delta, XD0, Tan, Y1, Y2, PX, Clip,ZeroY, WS, Acc);
true ->
Y = min(Cy, max(0,round(spline(Delta, Tan, Y1,Y2)))),
- %% io:format("Y1:~p Y(~p):~p Y2:~p~n",[round(Y1),round(X),round(Y),round(Y2)]),
splines(N-1, Delta, XD0, Tan, Y1, Y2, PX, Clip,ZeroY, WS,
[{round(PX), ZeroY-Y}|Acc])
end;
@@ -353,9 +329,8 @@ spline_tan(Y0, Y1, Y2, Y3) ->
-define(BW, 5).
-define(BH, 5).
-draw_borders(Type, NoGraphs, DC, {W,H}, Max0,
+draw_borders(Type, NoGraphs, DC, {W,H}, Max,
#paint{pen=Pen, pen2=Pen2, font=Font, small=Small}) ->
- Max = calc_max(Max0),
{Unit, MaxUnit} = bytes(Type, Max),
Str1 = observer_lib:to_str(MaxUnit),
Str2 = observer_lib:to_str(MaxUnit div 2),
@@ -442,9 +417,6 @@ draw_borders(Type, NoGraphs, DC, {W,H}, Max0,
end,
{GraphX0+1, GraphY1, ScaleW, ScaleH}.
-div2({Type, Int}) -> {Type, Int div 2};
-div2(Int) -> Int div 2.
-
uppercase([C|Rest]) ->
[C-$a+$A|Rest].
diff --git a/lib/runtime_tools/src/observer_backend.erl b/lib/runtime_tools/src/observer_backend.erl
index 2f8ffbcdb6..01e99f3f5e 100644
--- a/lib/runtime_tools/src/observer_backend.erl
+++ b/lib/runtime_tools/src/observer_backend.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2002-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2002-2012. 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
@@ -22,7 +22,7 @@
-export([vsn/0]).
%% observer stuff
--export([sys_info/0, get_table/3, get_table_list/2]).
+-export([sys_info/0, get_table/3, get_table_list/2, fetch_stats/2]).
%% etop stuff
-export([etop_collect/1]).
@@ -198,6 +198,22 @@ get_table_list(mnesia, Opts) ->
end,
lists:foldl(Info, [], mnesia:system_info(tables)).
+fetch_stats(Parent, Time) ->
+ erlang:system_flag(scheduler_wall_time, true),
+ process_flag(trap_exit, true),
+ fetch_stats_loop(Parent, Time),
+ erlang:system_flag(scheduler_wall_time, false).
+
+fetch_stats_loop(Parent, Time) ->
+ receive
+ _Msg -> normal
+ after Time ->
+ _M = Parent ! {stats, 1,
+ erlang:statistics(scheduler_wall_time),
+ erlang:statistics(io),
+ erlang:memory()},
+ fetch_stats(Parent, Time)
+ end.
%%
%% etop backend
%%