LGTM

On 11/02/2015 04:59 PM, 'Klaus Aehlig' via ganeti-devel wrote:
...by doing balanced summing, including computing the
delta in the update first, and improving memory footprint
by strictness.

Signed-off-by: Klaus Aehlig <[email protected]>
---
  src/Ganeti/Utils/Statistics.hs | 10 ++++------
  1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/Ganeti/Utils/Statistics.hs b/src/Ganeti/Utils/Statistics.hs
index 776f65a..cd830fb 100644
--- a/src/Ganeti/Utils/Statistics.hs
+++ b/src/Ganeti/Utils/Statistics.hs
@@ -79,13 +79,11 @@ data MapStat = MapStat TagTagMap deriving Show
instance Stat Double SumStat where
    calculate xs =
-    let addComponent s x =
-          let !s' = s + x
-          in s'
-        st = foldl' addComponent 0 xs
-    in SumStat st
+    let !sx = balancedSum xs
+    in SumStat sx
    update (SumStat s) x x' =
-    SumStat $ s + x' - x
+    let !sx' = s + (x' -x)
+    in SumStat sx'
    getValue (SumStat s) = s
instance Stat Double StdDevStat where

Reply via email to