From fdd8fa53a0a19b2c8796d3f507ccff0749ba80f6 Mon Sep 17 00:00:00 2001 From: Ian Luites Date: Fri, 17 Mar 2017 18:18:53 +0000 Subject: [PATCH] Fix issue #18. --- lib/wobserver/system/scheduler.ex | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/wobserver/system/scheduler.ex b/lib/wobserver/system/scheduler.ex index 12a2753..59c9b41 100644 --- a/lib/wobserver/system/scheduler.ex +++ b/lib/wobserver/system/scheduler.ex @@ -34,14 +34,17 @@ defmodule Wobserver.System.Scheduler do case last_utilization() do false -> get_utilization() - |> Enum.map(fn {_, u, t} -> u / t end) + |> Enum.map(fn {_, u, t} -> percentage(u, t) end) last -> get_utilization() |> Enum.zip(last) - |> Enum.map(fn {{_, u0, t0}, {_, u1, t1}} -> (u1 - u0) / (t1 - t0) end) + |> Enum.map(fn {{_, u0, t0}, {_, u1, t1}} -> percentage((u1 - u0), (t1 - t0)) end) end end + defp percentage(_, 0), do: 0 + defp percentage(u, t), do: u / t + defp get_utilization do util = :scheduler_wall_time