summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Statistics.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2013-03-28 22:31:57 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2013-03-29 12:46:11 -0400
commitf22ce193d4d42298ebd4e7e2379f31d5a870690c (patch)
tree7e880975ede80bc2561c97f5c2c6ebfb55a9ba7b /src/lib/Bcfg2/Statistics.py
parent20d1a9597bb039d693978c2b02e62e65826a5436 (diff)
downloadbcfg2-f22ce193d4d42298ebd4e7e2379f31d5a870690c.tar.gz
bcfg2-f22ce193d4d42298ebd4e7e2379f31d5a870690c.tar.bz2
bcfg2-f22ce193d4d42298ebd4e7e2379f31d5a870690c.zip
Statistics: fixed calculation of average time
Diffstat (limited to 'src/lib/Bcfg2/Statistics.py')
-rw-r--r--src/lib/Bcfg2/Statistics.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lib/Bcfg2/Statistics.py b/src/lib/Bcfg2/Statistics.py
index a869b03cd..01b0a80b1 100644
--- a/src/lib/Bcfg2/Statistics.py
+++ b/src/lib/Bcfg2/Statistics.py
@@ -30,8 +30,8 @@ class Statistic(object):
"""
self.min = min(self.min, value)
self.max = max(self.max, value)
- self.ave = (((self.ave * (self.count - 1)) + value) / self.count)
self.count += 1
+ self.ave = (((self.ave * (self.count - 1)) + value) / self.count)
def get_value(self):
""" Get a tuple of all the stats tracked on this named item.
@@ -46,6 +46,11 @@ class Statistic(object):
"""
return (self.name, (self.min, self.max, self.ave, self.count))
+ def __repr__(self):
+ return "%s(%s, (min=%s, avg=%s, max=%s, count=%s))" % (
+ self.__class__.__name__,
+ self.name, self.min, self.ave, self.max, self.count)
+
class Statistics(object):
""" A collection of named :class:`Statistic` objects. """