From 6f787e3d368eb248aee0854d99ed55e332d80170 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 5 Mar 2009 19:09:53 -0800 Subject: stats: create an enable phase, and a prepare phase. Enable more or less takes the place of check, but also allows stats to do some other configuration. Prepare moves all of the code that readies a stat for dumping into a separate function in preparation for supporting serialization of certain pieces of statistics data. While we're at it, clean up the visitor code and some of the python code. --- src/base/statistics.cc | 65 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 15 deletions(-) (limited to 'src/base/statistics.cc') diff --git a/src/base/statistics.cc b/src/base/statistics.cc index c77816f23..0a59248e7 100644 --- a/src/base/statistics.cc +++ b/src/base/statistics.cc @@ -32,6 +32,7 @@ #include #include #include +#include #include #include "base/callback.hh" @@ -174,6 +175,41 @@ Info::baseCheck() const return true; } +void +Info::enable() +{ +} + +void +VectorInfoBase::enable() +{ + size_type s = size(); + if (subnames.size() < s) + subnames.resize(s); + if (subdescs.size() < s) + subdescs.resize(s); +} + +void +VectorDistInfoBase::enable() +{ + size_type s = size(); + if (subnames.size() < s) + subnames.resize(s); + if (subdescs.size() < s) + subdescs.resize(s); +} + +void +Vector2dInfoBase::enable() +{ + if (subnames.size() < x) + subnames.resize(x); + if (subdescs.size() < x) + subdescs.resize(x); + if (y_subnames.size() < y) + y_subnames.resize(y); +} Formula::Formula() { @@ -244,11 +280,6 @@ Formula::zero() const return true; } -void -Formula::update() -{ -} - string Formula::str() const { @@ -256,7 +287,7 @@ Formula::str() const } void -check() +enable() { typedef list::iterator iter_t; @@ -277,17 +308,21 @@ check() statsList().sort(Info::less); - if (i == end) - return; - - iter_t last = i; - ++i; - for (i = statsList().begin(); i != end; ++i) { - if ((*i)->name == (*last)->name) - panic("same name used twice! name=%s\n", (*i)->name); + Info *info = *i; + info->enable(); + } +} - last = i; +void +prepare() +{ + list::iterator i = statsList().begin(); + list::iterator end = statsList().end(); + while (i != end) { + Info *info = *i; + info->prepare(); + ++i; } } -- cgit v1.2.3