Skip to content

Commit

Permalink
fix avg calc bug + WS cleanup in jobs_sampler_cpu
Browse files Browse the repository at this point in the history
  • Loading branch information
uwiger committed Jan 6, 2014
1 parent 6e209ea commit 98acefe
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/jobs_sampler_cpu.erl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
%% -*- erlang-indent-level: 4; indent-tabs-mode: nil -*-
%%==============================================================================
%% Copyright 2010 Erlang Solutions Ltd.
%%
Expand All @@ -18,7 +19,7 @@
%% File : jobs_sampler_cpu.erl
%% @author : Ulf Wiger <ulf.wiger@erlang-solutions.com>
%% @end
%% Description :
%% Description :
%%
%% Created : 15 Jan 2010 by Ulf Wiger <ulf.wiger@erlang-solutions.com>
%%-------------------------------------------------------------------
Expand Down Expand Up @@ -53,7 +54,7 @@ sample(_Timestamp, #st{} = S) ->
%% only one cpu
U;
[_,_|_] ->
%% This is a form of ad-hoc averaging, which tries to
%% This is a form of ad-hoc averaging, which tries to
%% account for the possibility that the application
%% loads the cores unevenly.
calc_avg_util(Utils)
Expand All @@ -70,8 +71,8 @@ calc_avg_util(Utils) ->
High = [U || U <- Utils,
B-U > 20],
lists:sum(High)/length(High);
{Low,High} ->
High+Low/2
{Low,High} ->
(High+Low)/2
end.


Expand All @@ -80,7 +81,7 @@ minmax([H|T]) ->
fun(X, {Min,Max}) ->
{erlang:min(X,Min), erlang:max(X,Max)}
end, {H,H}, T).


calc(History, #st{levels = Levels} = St) ->
L = jobs_sampler:calc(value, Levels, History),
Expand Down

0 comments on commit 98acefe

Please sign in to comment.