summaryrefslogtreecommitdiff
path: root/src/base/statistics.cc
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2009-03-05 19:09:53 -0800
committerNathan Binkert <nate@binkert.org>2009-03-05 19:09:53 -0800
commit6f787e3d368eb248aee0854d99ed55e332d80170 (patch)
tree22a153b41f7cd998ef3fcccb8a766eed7d1e92ab /src/base/statistics.cc
parent9f45fbaaa6e5f0fc63c63162b756c44b33e367f5 (diff)
downloadgem5-6f787e3d368eb248aee0854d99ed55e332d80170.tar.xz
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.
Diffstat (limited to 'src/base/statistics.cc')
-rw-r--r--src/base/statistics.cc65
1 files changed, 50 insertions, 15 deletions
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 <fstream>
#include <list>
#include <map>
+#include <set>
#include <string>
#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<Info *>::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<Info *>::iterator i = statsList().begin();
+ list<Info *>::iterator end = statsList().end();
+ while (i != end) {
+ Info *info = *i;
+ info->prepare();
+ ++i;
}
}