diff -r a625622cd8a1 -r aa3cff339427 src/python/m5/stats/__init__.py --- a/src/python/m5/stats/__init__.py Tue Jan 29 10:40:02 2013 +0000 +++ b/src/python/m5/stats/__init__.py Tue Jan 29 10:45:40 2013 +0000 @@ -159,6 +159,7 @@ d.sum = data.sum d.squares = data.squares + d.logs = data.logs d.samples = data.samples if isinstance(d, (Distribution, Histogram)): diff -r a625622cd8a1 -r aa3cff339427 src/python/m5/stats/display.py --- a/src/python/m5/stats/display.py Tue Jan 29 10:40:02 2013 +0000 +++ b/src/python/m5/stats/display.py Tue Jan 29 10:45:40 2013 +0000 @@ -296,6 +296,12 @@ p.value = v.mean() p.display(out) + # Only the histogram calculates a geometric mean + if type(v) == Histogram: + p.name = "%s::gmean" % self.name + p.value = v.gmean() + p.display(out) + p.name = "%s::stdev" % self.name p.value = v.stdev() p.display(out) diff -r a625622cd8a1 -r aa3cff339427 src/python/m5/stats/info.py --- a/src/python/m5/stats/info.py Tue Jan 29 10:40:02 2013 +0000 +++ b/src/python/m5/stats/info.py Tue Jan 29 10:45:40 2013 +0000 @@ -751,6 +751,7 @@ class Histogram(Deviation): ## @brief Reset the Histogram. Call the super class's clear method. def clear(self): + self.logs = 0 super(Histogram, self).clear() ## @brief Copy the histogram. Call the superclass copy method, then copy the @@ -762,8 +763,19 @@ copy.max = self.max copy.bucket_size = self.bucket_size copy.vector = self.vector[:] + copy.logs = self.logs return copy + ## @brief Calculate and return the geometric mean. + # @return The mean if the number of samples is greater than 0, float('nan') + # otherwise. + def gmean(self): + if self.samples == 0: + return float('nan') + + import math + return math.exp(self.logs / self.samples) + ## @brief Determine if it is possible to compare this histogram to another. # This is accomplished by checking that they are both of the same type, that # the min, max and bucket_size match and that the length of the vectors diff -r a625622cd8a1 -r aa3cff339427 src/python/m5/stats/sql.py --- a/src/python/m5/stats/sql.py Tue Jan 29 10:40:02 2013 +0000 +++ b/src/python/m5/stats/sql.py Tue Jan 29 10:45:40 2013 +0000 @@ -109,6 +109,7 @@ Column('sum', Float), Column('squares', Float), Column('samples', Float), + Column('logs', Float), Column('min', Float), Column('max', Float), Column('bucket', Float), @@ -243,6 +244,7 @@ sum = Column(Float) squares = Column(Float) samples = Column(Float) + logs = Column(Float) min = Column(Float) max = Column(Float) bucket = Column(Float) @@ -258,10 +260,11 @@ def __repr__(self): - return "" % (self.id, self.dump, self.sum, self.squares, - self.samples, self.min, self.max, self.bucket, self.vector, - self.min_val, self.max_val, self.underflow, self.overflow) + return "" % (self.id, self.dump, self.sum, self.squares, + self.samples, self.logs, self.min, self.max, self.bucket, + self.vector, self.min_val, self.max_val, self.underflow, + self.overflow) # @brief Class used to insert sparse histograms into the database. class SparseHistValueClass(Base): @@ -338,6 +341,9 @@ a = array.array('f', data.vector) temp.vector = a.tostring() + if type(data) == Histogram: + temp.logs = data.logs + if type(data) == Distribution: temp.min_val = data.min_val temp.max_val = data.max_val