From 66f115a2df61ab56e5ede8ba31836e20c622e0b3 Mon Sep 17 00:00:00 2001 From: Lisa Hsu Date: Tue, 21 Oct 2003 23:56:31 -0400 Subject: statistics.hh: same - bin printing statistics.cc: printing of bins! now all the nice binning functionality is actually useful cuz you can see the data it so nicely took. this prints out only the individual bin values. totals to come. statistics.hh: add a binned() function to each stat so that at print time, we can know if it's binned in order to print it right. base/statistics.hh: add a binned() function to each stat so that at print time, we can know if it's binned in order to print it right. base/statistics.cc: printing of bins! now all the nice binning functionality is actually useful cuz you can see the data it so nicely took. this prints out only the individual bin values. totals to come. base/statistics.hh: same - bin printing --HG-- extra : convert_revision : 09df9aae62b0e522230ee6bedcb51079346735a4 --- base/statistics.cc | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 3 deletions(-) (limited to 'base/statistics.cc') diff --git a/base/statistics.cc b/base/statistics.cc index abebcae53..a564ce4be 100644 --- a/base/statistics.cc +++ b/base/statistics.cc @@ -131,6 +131,10 @@ class Database typedef list list_t; typedef map map_t; + list bins; + map bin_names; + list_t binnedStats; + list_t allStats; list_t printStats; map_t map; @@ -145,6 +149,7 @@ class Database void check(); void regStat(Stat *stat); StatData *print(Stat *stat); + void regBin(BinBase *bin, std::string name); }; Database::Database() @@ -156,15 +161,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::iterator j = bins.begin(); + list::iterator bins_end=bins.end(); + + if (!bins.empty()) { + ccprintf(stream, "PRINTING BINNED STATS\n"); + while (j != bins_end) { + (*j)->activate(); + ::map::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 * @@ -221,6 +262,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) { @@ -274,6 +330,7 @@ Stat::Stat(bool reg) if (reg) StatDB().regStat(this); + #ifdef STAT_DEBUG number = ++total_stats; cprintf("I'm stat number %d\n",number); @@ -828,6 +885,12 @@ BinBase::memory() return mem; } +void +BinBase::regBin(BinBase *bin, std::string name) +{ + StatDB().regBin(bin, name); +} + } // namespace Detail void -- cgit v1.2.3