stats: fancy is a bad name

This commit is contained in:
Nathan Binkert 2009-05-13 07:18:02 -07:00
parent 74c595d739
commit cfa9c78100
4 changed files with 26 additions and 24 deletions

View file

@ -1271,7 +1271,7 @@ class DistStor
/** The parameters for a distribution stat. */ /** The parameters for a distribution stat. */
struct Params : public DistParams struct Params : public DistParams
{ {
Params() : DistParams(false) {} Params() : DistParams(Dist) {}
}; };
private: private:
@ -1405,12 +1405,12 @@ class DistStor
* Templatized storage and interface for a distribution that calculates mean * Templatized storage and interface for a distribution that calculates mean
* and variance. * and variance.
*/ */
class FancyStor class SampleStor
{ {
public: public:
struct Params : public DistParams struct Params : public DistParams
{ {
Params() : DistParams(true) {} Params() : DistParams(Deviation) {}
}; };
private: private:
@ -1425,7 +1425,7 @@ class FancyStor
/** /**
* Create and initialize this storage. * Create and initialize this storage.
*/ */
FancyStor(Info *info) SampleStor(Info *info)
: sum(Counter()), squares(Counter()), samples(Counter()) : sum(Counter()), squares(Counter()), samples(Counter())
{ } { }
@ -1481,12 +1481,12 @@ class FancyStor
* Templatized storage for distribution that calculates per tick mean and * Templatized storage for distribution that calculates per tick mean and
* variance. * variance.
*/ */
class AvgFancy class AvgSampleStor
{ {
public: public:
struct Params : public DistParams struct Params : public DistParams
{ {
Params() : DistParams(true) {} Params() : DistParams(Deviation) {}
}; };
private: private:
@ -1499,7 +1499,7 @@ class AvgFancy
/** /**
* Create and initialize this storage. * Create and initialize this storage.
*/ */
AvgFancy(Info *info) AvgSampleStor(Info *info)
: sum(Counter()), squares(Counter()) : sum(Counter()), squares(Counter())
{} {}
@ -2273,9 +2273,9 @@ class Distribution : public DistBase<Distribution, DistStor>
/** /**
* Calculates the mean and variance of all the samples. * Calculates the mean and variance of all the samples.
* @sa Stat, DistBase, FancyStor * @sa DistBase, SampleStor
*/ */
class StandardDeviation : public DistBase<StandardDeviation, FancyStor> class StandardDeviation : public DistBase<StandardDeviation, SampleStor>
{ {
public: public:
/** /**
@ -2289,9 +2289,9 @@ class StandardDeviation : public DistBase<StandardDeviation, FancyStor>
/** /**
* Calculates the per tick mean and variance of the samples. * Calculates the per tick mean and variance of the samples.
* @sa Stat, DistBase, AvgFancy * @sa DistBase, AvgSampleStor
*/ */
class AverageDeviation : public DistBase<AverageDeviation, AvgFancy> class AverageDeviation : public DistBase<AverageDeviation, AvgSampleStor>
{ {
public: public:
/** /**
@ -2305,7 +2305,7 @@ class AverageDeviation : public DistBase<AverageDeviation, AvgFancy>
/** /**
* A vector of distributions. * A vector of distributions.
* @sa Stat, VectorDistBase, DistStor * @sa VectorDistBase, DistStor
*/ */
class VectorDistribution : public VectorDistBase<VectorDistribution, DistStor> class VectorDistribution : public VectorDistBase<VectorDistribution, DistStor>
{ {
@ -2334,10 +2334,10 @@ class VectorDistribution : public VectorDistBase<VectorDistribution, DistStor>
/** /**
* This is a vector of StandardDeviation stats. * This is a vector of StandardDeviation stats.
* @sa Stat, VectorDistBase, FancyStor * @sa VectorDistBase, SampleStor
*/ */
class VectorStandardDeviation class VectorStandardDeviation
: public VectorDistBase<VectorStandardDeviation, FancyStor> : public VectorDistBase<VectorStandardDeviation, SampleStor>
{ {
public: public:
/** /**
@ -2355,10 +2355,10 @@ class VectorStandardDeviation
/** /**
* This is a vector of AverageDeviation stats. * This is a vector of AverageDeviation stats.
* @sa Stat, VectorDistBase, AvgFancy * @sa VectorDistBase, AvgSampleStor
*/ */
class VectorAverageDeviation class VectorAverageDeviation
: public VectorDistBase<VectorAverageDeviation, AvgFancy> : public VectorDistBase<VectorAverageDeviation, AvgSampleStor>
{ {
public: public:
/** /**

View file

@ -180,9 +180,11 @@ struct DistData
Counter samples; Counter samples;
}; };
enum DistType { Deviation, Dist };
struct DistParams : public StorageParams struct DistParams : public StorageParams
{ {
const bool fancy; const DistType type;
/** The minimum value to track. */ /** The minimum value to track. */
Counter min; Counter min;
@ -193,7 +195,7 @@ struct DistParams : public StorageParams
/** The number of buckets. Equal to (max-min)/bucket_size. */ /** The number of buckets. Equal to (max-min)/bucket_size. */
size_type buckets; size_type buckets;
explicit DistParams(bool f) : fancy(f) {} explicit DistParams(DistType t) : type(t) {}
}; };
class DistInfo : public Info class DistInfo : public Info

View file

@ -585,7 +585,7 @@ MySql::configure(const DistInfo &info)
const DistParams *params = const DistParams *params =
safe_cast<const DistParams *>(info.storageParams); safe_cast<const DistParams *>(info.storageParams);
if (!params->fancy) { if (params->type == Dist) {
stat.size = params->buckets; stat.size = params->buckets;
stat.min = params->min; stat.min = params->min;
stat.max = params->max; stat.max = params->max;
@ -602,7 +602,7 @@ MySql::configure(const VectorDistInfo &info)
const DistParams *params = const DistParams *params =
safe_cast<const DistParams *>(info.storageParams); safe_cast<const DistParams *>(info.storageParams);
if (!params->fancy) { if (params->type == Dist) {
stat.size = params->buckets; stat.size = params->buckets;
stat.min = params->min; stat.min = params->min;
stat.max = params->max; stat.max = params->max;
@ -789,7 +789,7 @@ MySql::output(const DistData &data, const DistParams *params)
newdata.data = data.samples; newdata.data = data.samples;
newdata.insert(); newdata.insert();
if (data.samples && !params->fancy) { if (data.samples && params->type == Dist) {
newdata.x = db_min_val; newdata.x = db_min_val;
newdata.data = data.min_val; newdata.data = data.min_val;
newdata.insert(); newdata.insert();

View file

@ -310,7 +310,7 @@ struct DistPrint
Counter max; Counter max;
Counter bucket_size; Counter bucket_size;
size_type size; size_type size;
bool fancy; DistType type;
const DistData &data; const DistData &data;
@ -347,7 +347,7 @@ DistPrint::init(const Text *text, const Info &info, const DistParams *params)
precision = info.precision; precision = info.precision;
descriptions = text->descriptions; descriptions = text->descriptions;
fancy = params->fancy; type = params->type;
min = params->min; min = params->min;
max = params->max; max = params->max;
bucket_size = params->bucket_size; bucket_size = params->bucket_size;
@ -383,7 +383,7 @@ DistPrint::operator()(ostream &stream) const
print.value = stdev; print.value = stdev;
print(stream); print(stream);
if (fancy) if (type == Deviation)
return; return;
assert(size == data.cvec.size()); assert(size == data.cvec.size());