// This is a hack to get this parameter from the old stats package.
namespace Statistics {
bool PrintDescriptions = true;
-DisplayMode default_mode = mode_simplescalar;
+DisplayMode DefaultMode = mode_simplescalar;
namespace Database
{
while (j != end) {
StatData *stat = *j;
if (stat->dodisplay())
- stat->display(stream);
+ stat->display(stream, mode);
++j;
}
++i;
while (i != end) {
StatData *stat = *i;
if (stat->dodisplay() && !stat->binned())
- stat->display(stream);
+ stat->display(stream, mode);
++i;
}
}
{
StatData *data = find(stat);
- if (data->print)
+ if (data->flags & print)
return;
- data->print = true;
+ data->flags |= print;
list_t::iterator j = printStats.insert(printStats.end(), data);
inplace_merge(printStats.begin(), j, printStats.end(), StatData::less);
void
DataAccess::setInit()
{
- statData()->init = true;
+ statData()->flags |= init;
}
void
bool
StatData::baseCheck() const
{
- if (!init) {
+ if (!(flags & init)) {
#ifdef STAT_DEBUG
cprintf("this is stat number %d\n",(*i)->number);
#endif
return false;
}
- if (print && name.empty()) {
+ if ((flags & print) && name.empty()) {
panic("all printable stats must be named");
return false;
}
result_t value;
string name;
string desc;
- int precision;
+ StatFlags flags;
DisplayMode mode;
- FormatFlags flags;
+ int precision;
result_t pdf;
result_t cdf;
ScalarPrint()
- : value(0.0), precision(0), mode(default_mode), flags(0),
+ : value(0.0), flags(0), mode(DefaultMode), precision(0),
pdf(NAN), cdf(NAN)
{}
if (mode == mode_simplescalar && flags & __substat) {
ccprintf(stream, "%32s %12s %10s %10s", name,
- ValueToString(value, mode, precision),
- pdfstr, cdfstr);
+ ValueToString(value, mode, precision), pdfstr, cdfstr);
} else {
ccprintf(stream, "%-40s %12s %10s %10s", name,
ValueToString(value, mode, precision), pdfstr, cdfstr);
string desc;
vector<string> subnames;
vector<string> subdescs;
- int precision;
+ StatFlags flags;
DisplayMode mode;
- FormatFlags flags;
+ int precision;
rvec_t vec;
result_t total;
VectorPrint()
- : subnames(0), subdescs(0), precision(-1), mode(default_mode),
- flags(0), total(NAN)
+ : subnames(0), subdescs(0), flags(0), mode(DefaultMode),
+ precision(-1), total(NAN)
{}
void operator()(ostream &stream) const;
{
string name;
string desc;
- int precision;
+ StatFlags flags;
DisplayMode mode;
- FormatFlags flags;
+ int precision;
result_t min_val;
result_t max_val;
print.precision = precision;
print.flags = flags;
+ print.mode = mode;
print.desc = desc;
print.name = base + "mean";
ScalarPrint print;
print.desc = (mode == mode_m5) ? desc : "";
- print.precision = precision;
- print.mode = mode;
print.flags = flags;
+ print.mode = mode;
+ print.precision = precision;
if (mode == mode_simplescalar) {
ccprintf(stream, "%-42s", base + "start_dist");
if (mode == mode_m5 || overflow > 0.0) {
print.name = base + "overflows";
print.value = overflow;
- if (mode == mode_m5 && total) {
+ if (total) {
print.pdf = overflow / total;
print.cdf += print.pdf;
}
}
void
-ScalarDataBase::display(ostream &stream) const
+ScalarDataBase::display(ostream &stream, DisplayMode mode) const
{
ScalarPrint print;
print.value = val();
print.name = name;
print.desc = desc;
- print.precision = precision;
print.flags = flags;
+ print.mode = mode;
+ print.precision = precision;
print(stream);
}
void
-VectorDataBase::display(ostream &stream) const
+VectorDataBase::display(ostream &stream, DisplayMode mode) const
{
int size = this->size();
const_cast<VectorDataBase *>(this)->update();
print.name = name;
print.desc = desc;
- print.mode = mode;
print.flags = flags;
+ print.mode = mode;
print.precision = precision;
print.vec = val();
print.total = total();
}
void
-Vector2dDataBase::display(ostream &stream) const
+Vector2dDataBase::display(ostream &stream, DisplayMode mode) const
{
const_cast<Vector2dDataBase *>(this)->update();
VectorPrint print;
print.subnames = y_subnames;
- print.mode = mode;
print.flags = flags;
+ print.mode = mode;
print.precision = precision;
if (!subnames.empty()) {
}
void
-DistDataBase::display(ostream &stream) const
+DistDataBase::display(ostream &stream, DisplayMode mode) const
{
const_cast<DistDataBase *>(this)->update();
print.name = name;
print.desc = desc;
- print.precision = precision;
- print.mode = mode;
print.flags = flags;
+ print.mode = mode;
+ print.precision = precision;
print.min_val = data.min_val;
print.max_val = data.max_val;
}
void
-VectorDistDataBase::display(ostream &stream) const
+VectorDistDataBase::display(ostream &stream, DisplayMode mode) const
{
const_cast<VectorDistDataBase *>(this)->update();
print.name = name +
(subnames[i].empty() ? ("_" + to_string(i)) : subnames[i]);
print.desc = subdescs[i].empty() ? desc : subdescs[i];
- print.precision = precision;
- print.mode = mode;
print.flags = flags;
+ print.mode = mode;
+ print.precision = precision;
print.min_val = data[i].min_val;
print.max_val = data[i].max_val;
* Define the storage for format flags.
* @todo Can probably shrink this.
*/
-typedef u_int32_t FormatFlags;
+typedef u_int32_t StatFlags;
+
/** Nothing extra to print. */
-const FormatFlags none = 0x0000;
+const StatFlags none = 0x00000000;
+/** This Stat is Initialized */
+const StatFlags init = 0x00000001;
+/** Print this stat. */
+const StatFlags print = 0x00000002;
/** Print the total. */
-const FormatFlags total = 0x0001;
+const StatFlags total = 0x00000010;
/** Print the percent of the total that this entry represents. */
-const FormatFlags pdf = 0x0002;
+const StatFlags pdf = 0x00000020;
/** Print the cumulative percentage of total upto this entry. */
-const FormatFlags cdf = 0x0004;
+const StatFlags cdf = 0x00000040;
+/** Print the distribution. */
+const StatFlags dist = 0x00000080;
/** Don't print if this is zero. */
-const FormatFlags nozero = 0x0010;
+const StatFlags nozero = 0x00000100;
/** Don't print if this is NAN */
-const FormatFlags nonan = 0x0020;
-/** Print the distribution. */
-const FormatFlags dist = 0x0100;
+const StatFlags nonan = 0x00000200;
/** Used for SS compatability. */
-const FormatFlags __substat = 0x8000;
+const StatFlags __substat = 0x80000000;
+
/** Mask of flags that can't be set directly */
-const FormatFlags __reserved = __substat;
+const StatFlags __reserved = init | print | __substat;
enum DisplayMode
{
mode_python
};
-extern DisplayMode default_mode;
+extern DisplayMode DefaultMode;
/* Contains the statistic implementation details */
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
struct StatData
{
- /** True if the stat has been initialized. */
- bool init;
- /** True if the stat should be printed. */
- bool print;
/** The name of the stat. */
std::string name;
/** The description of the stat. */
std::string desc;
+ /** The formatting flags. */
+ StatFlags flags;
/** The display precision. */
int precision;
- /** Display Mode */
- DisplayMode mode;
- /** The formatting flags. */
- FormatFlags flags;
/** A pointer to a prerequisite Stat. */
const StatData *prereq;
StatData()
- : init(false), print(false), precision(-1), mode(default_mode),
- flags(0), prereq(0)
+ : flags(none), precision(-1), prereq(0)
{}
virtual ~StatData();
* Print this stat to the given ostream.
* @param stream The stream to print to.
*/
- virtual void display(std::ostream &stream) const = 0;
+ virtual void display(std::ostream &stream, DisplayMode mode) const = 0;
bool dodisplay() const { return !prereq || !prereq->zero(); }
/**
virtual result_t val() const = 0;
virtual result_t total() const = 0;
- virtual void display(std::ostream &stream) const;
+ virtual void display(std::ostream &stream, DisplayMode mode) const;
};
template <class T>
mutable std::vector<std::string> subnames;
mutable std::vector<std::string> subdescs;
- virtual void display(std::ostream &stream) const;
+ virtual void display(std::ostream &stream, DisplayMode mode) const;
virtual size_t size() const = 0;
virtual const rvec_t &val() const = 0;
/** Local storage for the entry values, used for printing. */
DistDataData data;
- virtual void display(std::ostream &stream) const;
+ virtual void display(std::ostream &stream, DisplayMode mode) const;
virtual void update() = 0;
};
mutable rvec_t vec;
virtual size_t size() const = 0;
- virtual void display(std::ostream &stream) const;
+ virtual void display(std::ostream &stream, DisplayMode mode) const;
virtual void update()
{
int s = size();
mutable int x;
mutable int y;
- virtual void display(std::ostream &stream) const;
+ virtual void display(std::ostream &stream, DisplayMode mode) const;
virtual void update()
{
if (subnames.size() < x)
* @param f The new flags.
* @return A reference to this stat.
*/
- Parent &flags(FormatFlags _flags)
+ Parent &flags(StatFlags _flags)
{
statData()->flags |= _flags;
return self();
return samples == 0;
}
- void update(DistDataData *data, DisplayMode mode, const Params ¶ms)
+ void update(DistDataData *data, const Params ¶ms)
{
data->min = params.min;
data->max = params.max;
data->bucket_size = params.bucket_size;
data->size = params.size;
- if (mode == mode_m5)
- data->min_val = (min_val == INT_MAX) ? params.min : min_val;
- else
- data->min_val = params.min;
-
+ data->min_val = (min_val == INT_MAX) ? 0 : min_val;
data->max_val = (max_val == INT_MIN) ? 0 : max_val;
data->underflow = underflow;
data->overflow = overflow;
samples += number;
}
- void update(DistDataData *data, DisplayMode mode, const Params ¶ms)
+ void update(DistDataData *data, const Params ¶ms)
{
data->sum = sum;
data->squares = squares;
squares += value * value;
}
- void update(DistDataData *data, DisplayMode mode, const Params ¶ms)
+ void update(DistDataData *data, const Params ¶ms)
{
data->sum = sum;
data->squares = squares;
void update(DistDataBase *base)
{
base->data.fancy = storage_t::fancy;
- data()->update(&(base->data), base->mode, params);
+ data()->update(&(base->data), params);
}
/**
* @return True is stat is binned.
base->data.resize(size);
for (int i = 0; i < size; ++i) {
base->data[i].fancy = storage_t::fancy;
- data(i)->update(&(base->data[i]), base->mode, params);
+ data(i)->update(&(base->data[i]), params);
}
}
};
*/
void check();
-void dump(std::ostream &stream, DisplayMode mode = mode_simplescalar);
+void dump(std::ostream &stream, DisplayMode mode = DefaultMode);
void reset();
void registerResetCallback(Callback *cb);