Skip to content
Permalink
Browse files
Merge pull request #60 from paulo-ferraz-oliveira/fix/scheduler_usage
Don't throw an exception when erlang:statistics(scheduler_wall_time) …
  • Loading branch information
ferd committed Oct 11, 2017
2 parents a270acd + eb99031 commit 6e420aaa9bb8ee5ad376231f47698b9621811ef0
Showing 2 changed files with 4 additions and 2 deletions.
@@ -348,7 +348,7 @@ node_stats_print(N, Interval) ->
%% </ul>
%%
%% A scheduler isn't busy when doing anything else.
-spec scheduler_usage(Millisecs) -> [{SchedulerId, Usage}] when
-spec scheduler_usage(Millisecs) -> undefined | [{SchedulerId, Usage}] when
Millisecs :: non_neg_integer(),
SchedulerId :: pos_integer(),
Usage :: number().
@@ -212,12 +212,14 @@ time_fold(N, Interval, Fun, State, FoldFun, Init) ->

%% @doc Diffs two runs of erlang:statistics(scheduler_wall_time) and
%% returns usage metrics in terms of cores and 0..1 percentages.
-spec scheduler_usage_diff(SchedTime, SchedTime) -> [{SchedulerId, Usage}] when
-spec scheduler_usage_diff(SchedTime, SchedTime) -> undefined | [{SchedulerId, Usage}] when
SchedTime :: [{SchedulerId, ActiveTime, TotalTime}],
SchedulerId :: pos_integer(),
Usage :: number(),
ActiveTime :: non_neg_integer(),
TotalTime :: non_neg_integer().
scheduler_usage_diff(First, Last) when First =:= undefined orelse Last =:= undefined ->
undefined;
scheduler_usage_diff(First, Last) ->
lists:map(
fun ({{I, _A0, T}, {I, _A1, T}}) -> {I, 0.0}; % Avoid divide by zero

0 comments on commit 6e420aa

Please sign in to comment.