From 31109fc21a7a93875471f251c8aea201b3df4926 Mon Sep 17 00:00:00 2001 From: Jose A Ortega Ruiz Date: Mon, 29 Mar 2010 03:05:52 +0200 Subject: Tiny refactoring. Ignore-this: 5572afe54ca8aa3d13ebb34e431baa91 darcs-hash:20100329010552-748be-58fbdbfd053bb21ba1c4ebec82fa2bc5e85d0cff.gz --- Plugins/Monitors/Top.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/Monitors/Top.hs b/Plugins/Monitors/Top.hs index 911a079..93fd940 100644 --- a/Plugins/Monitors/Top.hs +++ b/Plugins/Monitors/Top.hs @@ -127,22 +127,22 @@ combineTimeInfos :: Times -> Times -> Times combineTimeInfos t0 t1 = M.intersectionWith timeDiff t1 t0 where timeDiff (n, x1) (_, x0) = (n, x1 - x0) -topProcesses :: TimesRef -> Float -> IO (Int, ([TimeInfo], [Meminfo])) +topProcesses :: TimesRef -> Float -> IO (Int, [TimeInfo], [Meminfo]) topProcesses tref scale = do - c1 <- getCurrentTime (t1, mis, len) <- timeMemInfos + c1 <- getCurrentTime atomicModifyIORef tref $ \(t0, c0) -> let scx = (fromRational . toRational $ diffUTCTime c1 c0) * scale / 100 ts = M.elems $ combineTimeInfos t0 t1 nts = map (\(nm, t) -> (nm, t / scx)) ts - in ((t1, c1), (len, (sortTop nts, sortTop mis))) + in ((t1, c1), (len, sortTop nts, sortTop mis)) showTimeInfo :: TimeInfo -> Monitor [String] showTimeInfo (n, t) = showInfo n (showDigits 1 t) t runTop :: TimesRef -> Float -> Float -> [String] -> Monitor String runTop tref scale mscale _ = do - (no, (ps, ms)) <- io $ topProcesses tref scale + (no, ps, ms) <- io $ topProcesses tref scale pstr <- mapM showTimeInfo ps mstr <- mapM (showMeminfo mscale) ms parseTemplate $! show no : concat (zipWith (++) pstr mstr) -- cgit v1.2.3