Vector2dInfoProxy(Stat &stat) : InfoProxy<Stat, Vector2dInfo>(stat) {}
};
+struct StorageParams
+{
+ virtual ~StorageParams();
+};
+
class InfoAccess
{
protected:
// Non formula statistics
//
//////////////////////////////////////////////////////////////////////
+/** The parameters for a distribution stat. */
+struct DistParams : public StorageParams
+{
+ const DistType type;
+ DistParams(DistType t) : type(t) {}
+};
/**
* Templatized storage and interface for a distrbution stat.
/** The parameters for a distribution stat. */
struct Params : public DistParams
{
+ /** 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;
+
Params() : DistParams(Dist) {}
};
{
const Params *params = safe_cast<const Params *>(info->storageParams);
+ assert(params->type == Dist);
+ data.type = params->type;
+ data.min = params->min;
+ data.max = params->max;
+ data.bucket_size = params->bucket_size;
+
data.min_val = (min_val == CounterLimits::max()) ? 0 : min_val;
data.max_val = (max_val == CounterLimits::min()) ? 0 : max_val;
data.underflow = underflow;
void
prepare(Info *info, DistData &data)
{
+ const Params *params = safe_cast<const Params *>(info->storageParams);
+
+ assert(params->type == Deviation);
+ data.type = params->type;
data.sum = sum;
data.squares = squares;
data.samples = samples;
void
prepare(Info *info, DistData &data)
{
+ const Params *params = safe_cast<const Params *>(info->storageParams);
+
+ assert(params->type == Deviation);
+ data.type = params->type;
data.sum = sum;
data.squares = squares;
data.samples = curTick;
/** Mask of flags that can't be set directly */
const FlagsType __reserved = init | display;
-struct StorageParams
-{
- virtual ~StorageParams();
-};
-
+struct StorageParams;
struct Visit;
class 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;
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:
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;
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;
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]);
}
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
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)
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;