diff options
author | Jose A. Ortega Ruiz <jao@gnu.org> | 2010-01-18 00:31:09 +0100 |
---|---|---|
committer | Jose A. Ortega Ruiz <jao@gnu.org> | 2010-01-18 00:31:09 +0100 |
commit | c37fdf4c1ad2d2c08fefe3adb172981f0c8c343f (patch) | |
tree | 680e262ea47398ac35ff06865c39e5b21ba9dddd /Plugins | |
parent | 75780faeb8d16686f8bedd169e04b430b4618e19 (diff) | |
download | xmobar-c37fdf4c1ad2d2c08fefe3adb172981f0c8c343f.tar.gz xmobar-c37fdf4c1ad2d2c08fefe3adb172981f0c8c343f.tar.bz2 |
Checking for division by 0 in MultiCpus
Ignore-this: 37834de5acc423c47e29c9e0a492b71c
darcs-hash:20100117233109-40885-cd534ebe12270f0c46426e6ffd057d03b59c7f86.gz
Diffstat (limited to 'Plugins')
-rw-r--r-- | Plugins/Monitors/MultiCpu.hs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Plugins/Monitors/MultiCpu.hs b/Plugins/Monitors/MultiCpu.hs index 02fa842..f1b7b20 100644 --- a/Plugins/Monitors/MultiCpu.hs +++ b/Plugins/Monitors/MultiCpu.hs @@ -45,12 +45,12 @@ parseMultiCpu = return $ zipWith (\x y -> zipWith (\a b -> (a + b) / 2.0) x y) p1 p0 percent :: [Float] -> [Float] -> [Float] -percent b a = map (/ tot) $ take 4 dif +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 formatMultiCpus :: [[Float]] -> Monitor [String] -formatMultiCpus [] = return $ take 15 (repeat "-1%") +formatMultiCpus [] = return $ take 15 (repeat "0%") formatMultiCpus xs = fmap concat $ mapM formatMultiCpu xs formatMultiCpu :: [Float] -> Monitor [String] |