summaryrefslogtreecommitdiff
path: root/base/statistics.cc
diff options
context:
space:
mode:
authorLisa Hsu <hsul@eecs.umich.edu>2003-10-22 00:29:45 -0400
committerLisa Hsu <hsul@eecs.umich.edu>2003-10-22 00:29:45 -0400
commita2c87bfdf2a37ca51bc186cd9123644bfbde0325 (patch)
tree377f6e28d0ffcd7e3b0430c6415fef1dd03661b9 /base/statistics.cc
parenta7c88ad2aef0ea8e743754ea93a0b4bcaf5bdc97 (diff)
parent66f115a2df61ab56e5ede8ba31836e20c622e0b3 (diff)
downloadgem5-a2c87bfdf2a37ca51bc186cd9123644bfbde0325.tar.xz
nate's reset stuff merged with my work on bin printing.
--HG-- extra : convert_revision : 438c94c90bfb3caffec461ad2c14b266cdf61494
Diffstat (limited to 'base/statistics.cc')
-rw-r--r--base/statistics.cc69
1 files changed, 66 insertions, 3 deletions
diff --git a/base/statistics.cc b/base/statistics.cc
index 2f52314b9..a2734cf37 100644
--- a/base/statistics.cc
+++ b/base/statistics.cc
@@ -132,6 +132,10 @@ class Database
typedef list<Stat *> list_t;
typedef map<const Stat *, StatData *> map_t;
+ list<BinBase *> bins;
+ map<const BinBase *, std::string > bin_names;
+ list_t binnedStats;
+
list_t allStats;
list_t printStats;
map_t map;
@@ -147,6 +151,7 @@ class Database
void reset();
void regStat(Stat *stat);
StatData *print(Stat *stat);
+ void regBin(BinBase *bin, std::string name);
};
Database::Database()
@@ -158,15 +163,51 @@ Database::~Database()
void
Database::dump(ostream &stream)
{
+
list_t::iterator i = printStats.begin();
list_t::iterator end = printStats.end();
-
while (i != end) {
Stat *stat = *i;
- if (stat->dodisplay())
- stat->display(stream);
+ if (stat->binned())
+ binnedStats.push_back(stat);
++i;
}
+
+ list<BinBase *>::iterator j = bins.begin();
+ list<BinBase *>::iterator bins_end=bins.end();
+
+ if (!bins.empty()) {
+ ccprintf(stream, "PRINTING BINNED STATS\n");
+ while (j != bins_end) {
+ (*j)->activate();
+ ::map<const BinBase *, std::string>::const_iterator iter;
+ iter = bin_names.find(*j);
+ if (iter == bin_names.end())
+ panic("a binned stat not found in names map!");
+ ccprintf(stream,"---%s Bin------------\n", (*iter).second);
+
+ list_t::iterator i = binnedStats.begin();
+ list_t::iterator end = binnedStats.end();
+ while (i != end) {
+ Stat *stat = *i;
+ if (stat->dodisplay())
+ stat->display(stream);
+ ++i;
+ }
+ ++j;
+ ccprintf(stream, "---------------------------------\n");
+ }
+ }
+
+ list_t::iterator k = printStats.begin();
+ list_t::iterator endprint = printStats.end();
+ ccprintf(stream, "*****ALL STATS*****\n");
+ while (k != endprint) {
+ Stat *stat = *k;
+ if (stat->dodisplay() && !stat->binned())
+ stat->display(stream);
+ ++k;
+ }
}
StatData *
@@ -235,6 +276,21 @@ Database::regStat(Stat *stat)
assert(success && "this should never fail");
}
+void
+Database::regBin(BinBase *bin, std::string name)
+{
+ if (bin_names.find(bin) != bin_names.end())
+ panic("shouldn't register bin twice");
+
+ bins.push_back(bin);
+
+ bool success = (bin_names.insert(make_pair(bin,name))).second;
+ assert(bin_names.find(bin) != bin_names.end());
+ assert(success && "this should not fail");
+
+ cprintf("registering %s\n", name);
+}
+
bool
Stat::less(Stat *stat1, Stat *stat2)
{
@@ -288,6 +344,7 @@ Stat::Stat(bool reg)
if (reg)
StatDB().regStat(this);
+
#ifdef STAT_DEBUG
number = ++total_stats;
cprintf("I'm stat number %d\n",number);
@@ -842,6 +899,12 @@ BinBase::memory()
return mem;
}
+void
+BinBase::regBin(BinBase *bin, std::string name)
+{
+ StatDB().regBin(bin, name);
+}
+
} // namespace Detail
void