From fad8b13adde99c3759b30dc4b16d5031d3e468fa Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Wed, 24 Dec 2003 01:45:56 -0500 Subject: Random cleanup to make things work a bit better base/statistics.cc: - give an internal name to statistics that aren't printable - speed up reset a tad - Make sure that the original value of the current bin is restored properly - check for the case where there are no subnames so we don't have an error - check to make sure that the formula's root is set before accessing it base/statistics.hh: - clean up includes a bit - deal with the case where there are no subnames - get rid of remnants of FS_MEASURE stuff --HG-- extra : convert_revision : 1e4338fc2b225647df47641b04c13b7046b2e114 --- base/statistics.cc | 57 ++++++++++++++++++++++++++++++++++-------------------- base/statistics.hh | 27 +++++++++++--------------- 2 files changed, 47 insertions(+), 37 deletions(-) (limited to 'base') diff --git a/base/statistics.cc b/base/statistics.cc index 9f528e712..191a72b07 100644 --- a/base/statistics.cc +++ b/base/statistics.cc @@ -168,9 +168,18 @@ Data::check() list_t::iterator end = allStats.end(); while (i != end) { - StatData *stat = *i; - assert(stat); - stat->check(); + StatData *data = *i; + assert(data); + data->check(); + ++i; + } + + i = allStats.begin(); + int j = 0; + while (i != end) { + StatData *data = *i; + if (!(data->flags & print)) + data->name = "__Stat" + to_string(j++); ++i; } } @@ -178,16 +187,20 @@ Data::check() void Data::reset() { + // reset non-binned stats list_t::iterator i = allStats.begin(); list_t::iterator end = allStats.end(); while (i != end) { - StatData *stat = *i; - stat->reset(); + StatData *data = *i; + if (!data->binned()) + data->reset(); ++i; } + // save the bin so we can go back to where we were MainBin *orig = MainBin::curBin(); + // reset binned stats list::iterator bi = bins.begin(); list::iterator be = bins.end(); while (bi != be) { @@ -196,15 +209,16 @@ Data::reset() i = allStats.begin(); while (i != end) { - StatData *stat = *i; - stat->reset(); + StatData *data = *i; + if (data->binned()) + data->reset(); ++i; } ++bi; } - if (orig) - orig->activate(); + // restore bin + MainBin::curBin() = orig; } void @@ -751,22 +765,23 @@ VectorDataBase::display(ostream &stream, DisplayMode mode) const print.vec = val(); print.total = total(); - for (int i = 0; i < size; ++i) { - if (!subnames[i].empty()) { - print.subnames = subnames; - print.subnames.resize(size); - for (int i = 0; i < size; ++i) { - if (!subnames[i].empty() && !subdescs[i].empty()) { - print.subdescs = subdescs; - print.subdescs.resize(size); - break; + if (!subnames.empty()) { + for (int i = 0; i < size; ++i) { + if (!subnames[i].empty()) { + print.subnames = subnames; + print.subnames.resize(size); + for (int i = 0; i < size; ++i) { + if (!subnames[i].empty() && !subdescs[i].empty()) { + print.subdescs = subdescs; + print.subdescs.resize(size); + break; + } } + break; } - break; } } - print(stream); } @@ -911,7 +926,7 @@ FormulaBase::size() const bool FormulaBase::binned() const { - return root->binned(); + return root && root->binned(); } void diff --git a/base/statistics.hh b/base/statistics.hh index 2aeae9e7f..6fe14dc7f 100644 --- a/base/statistics.hh +++ b/base/statistics.hh @@ -46,23 +46,20 @@ #define __STATISTICS_HH__ #include +#include +#include #include #include #include #include #include -#include - +#include "base/cprintf.hh" +#include "base/intmath.hh" #include "base/refcnt.hh" #include "base/str.hh" -#include "base/intmath.hh" -#include #include "sim/host.hh" -#ifdef FS_MEASURE -#include "base/trace.hh" -#endif // // Un-comment this to enable weirdo-stat debugging // @@ -235,12 +232,14 @@ struct VectorDataBase : public StatData virtual result_t total() const = 0; virtual void update() { - int s = size(); - if (subnames.size() < s) - subnames.resize(s); + if (!subnames.empty()) { + int s = size(); + if (subnames.size() < s) + subnames.resize(s); - if (subdescs.size() < s) - subdescs.resize(s); + if (subdescs.size() < s) + subdescs.resize(s); + } } }; @@ -273,7 +272,6 @@ class VectorData : public VectorDataBase } }; - struct DistDataData { result_t min_val; @@ -2178,9 +2176,6 @@ struct MainBin activate() { setCurBin(this); -#ifdef FS_MEASURE - DPRINTF(TCPIP, "activating %s Bin\n", name()); -#endif } class BinBase -- cgit v1.2.3