diff options
Diffstat (limited to 'base/statistics.cc')
-rw-r--r-- | base/statistics.cc | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/base/statistics.cc b/base/statistics.cc index 69b663dbb..737f8f73b 100644 --- a/base/statistics.cc +++ b/base/statistics.cc @@ -129,8 +129,8 @@ class Database typedef list<Stat *> list_t; typedef map<const Stat *, StatData *> map_t; - list<GenBin *> bins; - map<const GenBin *, std::string > bin_names; + list<MainBin *> bins; + map<const MainBin *, std::string > bin_names; list_t binnedStats; list_t allStats; @@ -148,7 +148,7 @@ class Database void reset(); void regStat(Stat *stat); StatData *print(Stat *stat); - void regBin(GenBin *bin, std::string name); + void regBin(MainBin *bin, std::string name); }; Database::Database() @@ -171,14 +171,14 @@ Database::dump(ostream &stream) } #endif //FS_MEASURE - list<GenBin *>::iterator j = bins.begin(); - list<GenBin *>::iterator bins_end=bins.end(); + list<MainBin *>::iterator j = bins.begin(); + list<MainBin *>::iterator bins_end=bins.end(); if (!bins.empty()) { ccprintf(stream, "PRINTING BINNED STATS\n"); while (j != bins_end) { (*j)->activate(); - map<const GenBin *, std::string>::const_iterator iter; + map<const MainBin *, std::string>::const_iterator iter; iter = bin_names.find(*j); if (iter == bin_names.end()) panic("a binned stat not found in names map!"); @@ -272,12 +272,12 @@ Database::reset() ++i; } - MainBin *orig = MainBin::current(); + MainBin *orig = MainBin::curBin(); - list<GenBin *>::iterator bi = bins.begin(); - list<GenBin *>::iterator be = bins.end(); + list<MainBin *>::iterator bi = bins.begin(); + list<MainBin *>::iterator be = bins.end(); while (bi != be) { - GenBin *bin = *bi; + MainBin *bin = *bi; bin->activate(); i = allStats.begin(); @@ -289,7 +289,8 @@ Database::reset() ++bi; } - orig->activate(); + if (orig) + orig->activate(); } void @@ -307,7 +308,7 @@ Database::regStat(Stat *stat) } void -Database::regBin(GenBin *bin, std::string name) +Database::regBin(MainBin *bin, std::string name) { if (bin_names.find(bin) != bin_names.end()) panic("shouldn't register bin twice"); @@ -747,7 +748,7 @@ VectorDisplay(std::ostream &stream, _pdf = vec[i] / _total; _cdf += _pdf; } else { - _pdf = _cdf = NAN; + _pdf = _cdf = 0.0; } if (!(myflags & cdf)) { PrintOne(stream, vec[i], subname, subdesc, myprecision, @@ -909,36 +910,35 @@ FancyDisplay(ostream &stream, const string &name, const string &desc, PrintOne(stream, total, "**Ignore: " + name + NAMESEP + "TOT", desc, precision, flags); } -BinBase::BinBase() - : mem(NULL), memsize(-1) +} // namespace Detail + +MainBin::MainBin(const std::string &name) + : _name(name), mem(NULL), memsize(-1) { + Detail::StatDB().regBin(this, name); } -BinBase::~BinBase() +MainBin::~MainBin() { if (mem) delete [] mem; } char * -BinBase::memory() +MainBin::memory(off_t off) { if (!mem) { mem = new char[memsize]; memset(mem, 0, memsize); } - return mem; -} + if (memsize == -1) + memsize = CeilPow2((size_t) offset()); -void -GenBin::regBin(GenBin *bin, std::string name) -{ - Detail::StatDB().regBin(bin, name); + assert(offset() <= size()); + return mem + off; } -} // namespace Detail - void check() { |