From cd56e4e08e86b5ee82b1e395356a0bccb53de74d Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Tue, 18 Jan 2005 17:55:35 -0500 Subject: Ability to check formulas --HG-- extra : convert_revision : 68a2a19cceb4a8cf8a2798ee5c019d25c0fca3cc --- util/stats/info.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'util/stats/info.py') diff --git a/util/stats/info.py b/util/stats/info.py index d11619765..644c15264 100644 --- a/util/stats/info.py +++ b/util/stats/info.py @@ -3,6 +3,8 @@ import operator, re, types source = None display_run = 0 +global globalTicks +globalTicks = None def issequence(t): return isinstance(t, types.TupleType) or isinstance(t, types.ListType) @@ -130,6 +132,7 @@ def cmp(a, b): return 1 class Statistic(object): + def __init__(self, data): self.__dict__.update(data.__dict__) if not self.__dict__.has_key('value'): @@ -138,9 +141,25 @@ class Statistic(object): self.__dict__['bins'] = None if not self.__dict__.has_key('ticks'): self.__dict__['ticks'] = None + if 'vc' not in self.__dict__: + self.vc = {} def __getattribute__(self, attr): + if attr == 'ticks': + if self.__dict__['ticks'] != globalTicks: + self.__dict__['value'] = None + self.__dict__['ticks'] = globalTicks + return self.__dict__['ticks'] if attr == 'value': + if self.__dict__['ticks'] != globalTicks: + if self.__dict__['ticks'] != None and \ + len(self.__dict__['ticks']) == 1: + self.vc[self.__dict__['ticks'][0]] = self.__dict__['value'] + self.__dict__['ticks'] = globalTicks + if len(globalTicks) == 1 and self.vc.has_key(globalTicks[0]): + self.__dict__['value'] = self.vc[globalTicks[0]] + else: + self.__dict__['value'] = None if self.__dict__['value'] == None: self.__dict__['value'] = self.getValue() return self.__dict__['value'] @@ -152,11 +171,12 @@ class Statistic(object): if attr == 'bins': if value is not None: value = source.getBin(value) - elif attr == 'ticks' and type(value) is str: - value = [ int(x) for x in value.split() ] + #elif attr == 'ticks' and type(value) is str: + # value = [ int(x) for x in value.split() ] self.__dict__[attr] = value self.__dict__['value'] = None + self.vc = {} else: super(Statistic, self).__setattr__(attr, value) -- cgit v1.2.3 From 886f905785561372413ea95dc551a0f269e28bac Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Wed, 19 Jan 2005 18:40:02 -0500 Subject: added total bytes/bandwidth/packets formulas to nics cleaned up stability code and wrote some better help for stats.py fixed sample bug in info.py dev/ns_gige.cc: dev/ns_gige.hh: dev/sinic.cc: dev/sinic.hh: add total bandwidth/packets/bytes stats util/stats/info.py: fixed samples bug util/stats/stats.py: cleaned up stability code and wrote a bit better help --HG-- extra : convert_revision : cae06f4fac744d7a51ee0909f21f03509151ea8f --- util/stats/info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util/stats/info.py') diff --git a/util/stats/info.py b/util/stats/info.py index 644c15264..fb46a2d55 100644 --- a/util/stats/info.py +++ b/util/stats/info.py @@ -307,7 +307,7 @@ class Scalar(Statistic,FormulaStat): class Vector(Statistic,FormulaStat): def getValue(self): - return source.data(self, self.bins); + return source.data(self, self.bins, self.ticks); def display(self): import display -- cgit v1.2.3 From 52403a5ddf1e02f53d0624254f41e27e3914df29 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 3 Feb 2005 17:04:54 -0500 Subject: get rid of defined and just access the env dict directly get rid of the alias for true to True and false to False to keep consistent python syntax. util/stats/info.py: Fix typo --HG-- extra : convert_revision : e69588a8de52424e043315e70008ca3a3ede7d5b --- util/stats/info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util/stats/info.py') diff --git a/util/stats/info.py b/util/stats/info.py index fb46a2d55..01d7bdb0f 100644 --- a/util/stats/info.py +++ b/util/stats/info.py @@ -324,7 +324,7 @@ class Vector(Statistic,FormulaStat): def __eq__(self, other): if issequence(self.value) != issequence(other.value): - return false + return False if issequence(self.value): if len(self.value) != len(other.value): -- cgit v1.2.3