summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Statistics.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Bcfg2/Server/Statistics.py')
-rw-r--r--src/lib/Bcfg2/Server/Statistics.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/lib/Bcfg2/Server/Statistics.py b/src/lib/Bcfg2/Server/Statistics.py
index 8a6ff54c4..dfb698b61 100644
--- a/src/lib/Bcfg2/Server/Statistics.py
+++ b/src/lib/Bcfg2/Server/Statistics.py
@@ -30,10 +30,10 @@ class Statistic(object):
:param value: The value to add to this statistic
:type value: int or float
"""
- self.min = min(self.min, value)
- self.max = max(self.max, value)
- self.ave = (((self.ave * (self.count - 1)) + value) / self.count)
+ self.min = min(self.min, float(value))
+ self.max = max(self.max, float(value))
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.
@@ -48,6 +48,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. """