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;
}
}
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<MainBin *>::iterator bi = bins.begin();
list<MainBin *>::iterator be = bins.end();
while (bi != be) {
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
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);
}
bool
FormulaBase::binned() const
{
- return root->binned();
+ return root && root->binned();
}
void
#define __STATISTICS_HH__
#include <algorithm>
+#include <cassert>
+#include <cmath>
#include <functional>
#include <iosfwd>
#include <sstream>
#include <string>
#include <vector>
-#include <assert.h>
-
+#include "base/cprintf.hh"
+#include "base/intmath.hh"
#include "base/refcnt.hh"
#include "base/str.hh"
-#include "base/intmath.hh"
-#include <math.h>
#include "sim/host.hh"
-#ifdef FS_MEASURE
-#include "base/trace.hh"
-#endif
//
// Un-comment this to enable weirdo-stat debugging
//
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);
+ }
}
};
}
};
-
struct DistDataData
{
result_t min_val;
activate()
{
setCurBin(this);
-#ifdef FS_MEASURE
- DPRINTF(TCPIP, "activating %s Bin\n", name());
-#endif
}
class BinBase