summaryrefslogtreecommitdiff
path: root/src/base/stats
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2010-07-21 18:54:53 -0700
committerNathan Binkert <nate@binkert.org>2010-07-21 18:54:53 -0700
commit21bf6ff1019cb1334596da8488268eeaea3753cc (patch)
treecbcfd55b702e7e235aad41031c6840e2c3c571b1 /src/base/stats
parent2a1309f2134986edcbff846aff5951ec1e8df6e1 (diff)
downloadgem5-21bf6ff1019cb1334596da8488268eeaea3753cc.tar.xz
stats: unify the two stats distribution type better
Diffstat (limited to 'src/base/stats')
-rw-r--r--src/base/stats/info.hh31
-rw-r--r--src/base/stats/mysql.cc14
-rw-r--r--src/base/stats/text.cc36
3 files changed, 24 insertions, 57 deletions
diff --git a/src/base/stats/info.hh b/src/base/stats/info.hh
index 4987fa810..e5b9e4a65 100644
--- a/src/base/stats/info.hh
+++ b/src/base/stats/info.hh
@@ -61,11 +61,7 @@ const FlagsType nonan = 0x0200;
/** Mask of flags that can't be set directly */
const FlagsType __reserved = init | display;
-struct StorageParams
-{
- virtual ~StorageParams();
-};
-
+struct StorageParams;
struct Visit;
class Info
@@ -168,8 +164,15 @@ class VectorInfo : public Info
virtual Result total() const = 0;
};
+enum DistType { Deviation, Dist };
+
struct DistData
{
+ DistType type;
+ Counter min;
+ Counter max;
+ Counter bucket_size;
+
Counter min_val;
Counter max_val;
Counter underflow;
@@ -180,24 +183,6 @@ struct DistData
Counter samples;
};
-enum DistType { Deviation, Dist };
-
-struct DistParams : public StorageParams
-{
- const DistType type;
-
- /** The minimum value to track. */
- Counter min;
- /** The maximum value to track. */
- Counter max;
- /** The number of entries in each bucket. */
- Counter bucket_size;
- /** The number of buckets. Equal to (max-min)/bucket_size. */
- size_type buckets;
-
- explicit DistParams(DistType t) : type(t) {}
-};
-
class DistInfo : public Info
{
public:
diff --git a/src/base/stats/mysql.cc b/src/base/stats/mysql.cc
index 6ef173f50..9d2dadb01 100644
--- a/src/base/stats/mysql.cc
+++ b/src/base/stats/mysql.cc
@@ -481,9 +481,10 @@ MySql::configure(const DistInfo &info)
if (!configure(info, "DIST"))
return;
- const DistParams *params =
- safe_cast<const DistParams *>(info.storageParams);
- if (params->type == Dist) {
+ const DistStor::Params *params =
+ dynamic_cast<const DistStor::Params *>(info.storageParams);
+ if (params) {
+ assert(params->type == Dist);
stat.size = params->buckets;
stat.min = params->min;
stat.max = params->max;
@@ -498,9 +499,10 @@ MySql::configure(const VectorDistInfo &info)
if (!configure(info, "VECTORDIST"))
return;
- const DistParams *params =
- safe_cast<const DistParams *>(info.storageParams);
- if (params->type == Dist) {
+ const DistStor::Params *params =
+ dynamic_cast<const DistStor::Params *>(info.storageParams);
+ if (params) {
+ assert(params->type == Dist);
stat.size = params->buckets;
stat.min = params->min;
stat.max = params->max;
diff --git a/src/base/stats/text.cc b/src/base/stats/text.cc
index 87bb05323..425a917ef 100644
--- a/src/base/stats/text.cc
+++ b/src/base/stats/text.cc
@@ -306,30 +306,24 @@ struct DistPrint
bool descriptions;
int precision;
- Counter min;
- Counter max;
- Counter bucket_size;
- size_type size;
- DistType type;
-
const DistData &data;
DistPrint(const Text *text, const DistInfo &info);
DistPrint(const Text *text, const VectorDistInfo &info, int i);
- void init(const Text *text, const Info &info, const DistParams *params);
+ void init(const Text *text, const Info &info);
void operator()(ostream &stream) const;
};
DistPrint::DistPrint(const Text *text, const DistInfo &info)
: data(info.data)
{
- init(text, info, safe_cast<const DistParams *>(info.storageParams));
+ init(text, info);
}
DistPrint::DistPrint(const Text *text, const VectorDistInfo &info, int i)
: data(info.data[i])
{
- init(text, info, safe_cast<const DistParams *>(info.storageParams));
+ init(text, info);
name = info.name + "_" +
(info.subnames[i].empty() ? (to_string(i)) : info.subnames[i]);
@@ -339,27 +333,13 @@ DistPrint::DistPrint(const Text *text, const VectorDistInfo &info, int i)
}
void
-DistPrint::init(const Text *text, const Info &info, const DistParams *params)
+DistPrint::init(const Text *text, const Info &info)
{
name = info.name;
desc = info.desc;
flags = info.flags;
precision = info.precision;
descriptions = text->descriptions;
-
- type = params->type;
- switch (type) {
- case Dist:
- min = params->min;
- max = params->max;
- bucket_size = params->bucket_size;
- size = params->buckets;
- break;
- case Deviation:
- break;
- default:
- panic("unknown distribution type");
- }
}
void
@@ -391,10 +371,10 @@ DistPrint::operator()(ostream &stream) const
print.value = stdev;
print(stream);
- if (type == Deviation)
+ if (data.type == Deviation)
return;
- assert(size == data.cvec.size());
+ size_t size = data.cvec.size();
Result total = 0.0;
if (data.underflow != NAN)
@@ -419,8 +399,8 @@ DistPrint::operator()(ostream &stream) const
stringstream namestr;
namestr << base;
- Counter low = i * bucket_size + min;
- Counter high = ::min(low + bucket_size - 1.0, max);
+ Counter low = i * data.bucket_size + data.min;
+ Counter high = ::min(low + data.bucket_size - 1.0, data.max);
namestr << low;
if (low < high)
namestr << "-" << high;