From 3d100946bc6f900fb5a4035213f4c8c1fd81f062 Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Tue, 19 Jan 2010 03:17:53 +0100 Subject: Tiny refactoring Ignore-this: 404b0000887a9c4dfc5209a9f647d561 darcs-hash:20100119021753-40885-3dd49b3e05ab638a27f51f79e1ee0ad34563f001.gz --- Plugins/Monitors/MultiCpu.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Plugins/Monitors') diff --git a/Plugins/Monitors/MultiCpu.hs b/Plugins/Monitors/MultiCpu.hs index 39e48c8..43283a8 100644 --- a/Plugins/Monitors/MultiCpu.hs +++ b/Plugins/Monitors/MultiCpu.hs @@ -41,26 +41,26 @@ parseCpuData = do (as, bs) <- doActionTwiceWithDelay 950000 cpuData let p0 = zipWith percent bs as return p0 - -- (as', bs') <- doActionTwiceWithDelay 350000 cpuData - -- let p1 = zipWith percent bs' as' - -- return $ zipWith (\x y -> zipWith (\a b -> (a + b) / 2.0) x y) p1 p0 percent :: [Float] -> [Float] -> [Float] percent b a = if tot > 0 then map (/ tot) $ take 4 dif else [0, 0, 0, 0] where dif = zipWith (-) b a tot = foldr (+) 0 dif +emptyPercs :: [String] +emptyPercs = repeat " 0%" + formatMultiCpus :: [[Float]] -> Monitor [String] -formatMultiCpus [] = return $ take 15 (repeat " 0%") +formatMultiCpus [] = return $ take 15 emptyPercs formatMultiCpus xs = fmap concat $ mapM formatCpu xs formatCpu :: [Float] -> Monitor [String] formatCpu x - | length x < 4 = return $ take 5 (repeat "") + | length x < 4 = return $ take 5 emptyPercs | otherwise = mapM (showWithColors f) . map (* 100) $ (t:x) where f s = pad $ floatToPercent (s / 100) t = foldr (+) 0 $ take 3 x - pad s = take (4 - length s) (repeat ' ') ++ s + pad s = take (4 - length s) " " ++ s runMultiCpu :: [String] -> Monitor String runMultiCpu _ = -- cgit v1.2.3