summaryrefslogtreecommitdiff
path: root/util/stats/display.py
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2005-10-21 16:29:13 -0400
committerNathan Binkert <binkertn@umich.edu>2005-10-21 16:29:13 -0400
commite00237e49e3cb171a1235f5de43587e8eb31ec2c (patch)
tree4430d3aae17e97a048be4f803264c6830a605df3 /util/stats/display.py
parent8ab674582e88582f06d729237d9cb1c00562451e (diff)
downloadgem5-e00237e49e3cb171a1235f5de43587e8eb31ec2c.tar.xz
Major cleanup of the statistics handling code
util/stats/db.py: Build a result object as the result of a query operation so it is easier to populate and contains a bit more information than just a big dict. Also change the next level data into a matrix instead of a dict of dicts. Move the "get" function into the Database object. (The get function is used by the output parsing function as the interface for accessing backend storage, same interface for profile stuff.) Change the old get variable to the method variable, it describes how the get works, (whether using sum, stdev, etc.) util/stats/display.py: Clean up the display functions, mostly formatting. Handle values the way they should be now. util/stats/info.py: Totally re-work how values are accessed from their data store. Access individual values on demand instead of calculating everything and passing up a huge result from the bottom. This impacts the way that proxying works, and in general, everything is now esentially a proxy for the lower level database. Provide new operators: unproxy, scalar, vector, value, values, total, and len which retrieve the proper result from the object they are called on. Move the ProxyGroup stuff (proxies of proxies!) here from the now gone proxy.py file and integrate the shared parts of the code. The ProxyGroup stuff allows you to write formulas without specifying the statistics until evaluation time. Get rid of global variables! util/stats/output.py: Move the dbinfo stuff into the Database itself. Each source should have it's own get() function for accessing it's data. This get() function behaves a bit differently than before in that it can return vectors as well, deal with these vectors and with no result conditions better. util/stats/stats.py: the info module no longer has the source global variable, just create the database source and pass it around as necessary --HG-- extra : convert_revision : 8e5aa228e5d3ae8068ef9c40f65b3a2f9e7c0cff
Diffstat (limited to 'util/stats/display.py')
-rw-r--r--util/stats/display.py97
1 files changed, 48 insertions, 49 deletions
diff --git a/util/stats/display.py b/util/stats/display.py
index 629684ca4..fbcff5c70 100644
--- a/util/stats/display.py
+++ b/util/stats/display.py
@@ -26,7 +26,7 @@
class Value:
def __init__(self, value, precision, percent = False):
- self.value = value
+ self.value = float(value)
self.precision = precision
self.percent = percent
def __str__(self):
@@ -90,61 +90,60 @@ class Print:
class VectorDisplay:
def display(self):
+ if not self.value:
+ return
+
p = Print()
p.flags = self.flags
p.precision = self.precision
- if isinstance(self.value, (list, tuple)):
- if not len(self.value):
- return
-
- mytotal = reduce(lambda x,y: float(x) + float(y), self.value)
- mycdf = 0.0
+ if not isinstance(self.value, (list, tuple)):
+ p.name = self.name
+ p.desc = self.desc
+ p.value = self.value
+ p.display()
+ return
- value = self.value
+ mytotal = reduce(lambda x,y: float(x) + float(y), self.value)
+ mycdf = 0.0
- if display_all:
- subnames = [ '[%d]' % i for i in range(len(value)) ]
- else:
- subnames = [''] * len(value)
-
- if self.__dict__.has_key('subnames'):
- for i,each in enumerate(self.subnames):
- if len(each) > 0:
- subnames[i] = '.%s' % each
-
- subdescs = [self.desc]*len(value)
- if self.__dict__.has_key('subdescs'):
- for i in xrange(min(len(value), len(self.subdescs))):
- subdescs[i] = self.subdescs[i]
-
- for val,sname,sdesc in map(None, value, subnames, subdescs):
- if mytotal > 0.0:
- mypdf = float(val) / float(mytotal)
- mycdf += mypdf
- if (self.flags & flags_pdf):
- p.pdf = mypdf
- p.cdf = mycdf
-
- if len(sname) == 0:
- continue
-
- p.name = self.name + sname
- p.desc = sdesc
- p.value = val
- p.display()
-
- if (self.flags & flags_total):
- if (p.__dict__.has_key('pdf')): del p.__dict__['pdf']
- if (p.__dict__.has_key('cdf')): del p.__dict__['cdf']
- p.name = self.name + '.total'
- p.desc = self.desc
- p.value = mytotal
- p.display()
+ value = self.value
+ if display_all:
+ subnames = [ '[%d]' % i for i in range(len(value)) ]
else:
- p.name = self.name
- p.desc = self.desc
- p.value = self.value
+ subnames = [''] * len(value)
+
+ if self.__dict__.has_key('subnames'):
+ for i,each in enumerate(self.subnames):
+ if len(each) > 0:
+ subnames[i] = '.%s' % each
+
+ subdescs = [self.desc]*len(value)
+ if self.__dict__.has_key('subdescs'):
+ for i in xrange(min(len(value), len(self.subdescs))):
+ subdescs[i] = self.subdescs[i]
+
+ for val,sname,sdesc in map(None, value, subnames, subdescs):
+ if mytotal > 0.0:
+ mypdf = float(val) / float(mytotal)
+ mycdf += mypdf
+ if (self.flags & flags_pdf):
+ p.pdf = mypdf
+ p.cdf = mycdf
+
+ if len(sname) == 0:
+ continue
+
+ p.name = self.name + sname
+ p.desc = sdesc
+ p.value = val
p.display()
+ if (self.flags & flags_total):
+ if (p.__dict__.has_key('pdf')): del p.__dict__['pdf']
+ if (p.__dict__.has_key('cdf')): del p.__dict__['cdf']
+ p.name = self.name + '.total'
+ p.desc = self.desc
+ p.value = mytotal
+ p.display()