From eac71fc1109f2edc6b71e62a6cff38d762bebe63 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Tue, 25 Sep 2012 11:49:15 -0400 Subject: expanded pylint coverage --- src/lib/Bcfg2/Statistics.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/lib/Bcfg2/Statistics.py') diff --git a/src/lib/Bcfg2/Statistics.py b/src/lib/Bcfg2/Statistics.py index bee90bbf4..2379dd1c8 100644 --- a/src/lib/Bcfg2/Statistics.py +++ b/src/lib/Bcfg2/Statistics.py @@ -1,4 +1,10 @@ +""" module for tracking execution time statistics from the bcfg2 +server core """ + + class Statistic(object): + """ a single named statistic, tracking minimum, maximum, and + average execution time, and number of invocations """ def __init__(self, name, initial_value): self.name = name self.min = float(initial_value) @@ -7,24 +13,29 @@ class Statistic(object): self.count = 1 def add_value(self, value): + """ add a value to the statistic """ 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 def get_value(self): + """ get a tuple of all the stats tracked on this named item """ return (self.name, (self.min, self.max, self.ave, self.count)) class Statistics(object): + """ A collection of named statistics """ def __init__(self): self.data = dict() def add_value(self, name, value): + """ add a value to the named statistic """ if name not in self.data: self.data[name] = Statistic(name, value) else: self.data[name].add_value(value) def display(self): + """ return a dict of all statistics """ return dict([value.get_value() for value in list(self.data.values())]) -- cgit v1.2.3-1-g7c22