From 21bf6ff1019cb1334596da8488268eeaea3753cc Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Wed, 21 Jul 2010 18:54:53 -0700 Subject: stats: unify the two stats distribution type better --- src/base/statistics.hh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/base/statistics.hh') diff --git a/src/base/statistics.hh b/src/base/statistics.hh index 5fca376e3..8c229d419 100644 --- a/src/base/statistics.hh +++ b/src/base/statistics.hh @@ -160,6 +160,11 @@ class Vector2dInfoProxy : public InfoProxy Vector2dInfoProxy(Stat &stat) : InfoProxy(stat) {} }; +struct StorageParams +{ + virtual ~StorageParams(); +}; + class InfoAccess { protected: @@ -1269,6 +1274,12 @@ class Vector2dBase : public DataWrapVec2d // 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. @@ -1279,6 +1290,15 @@ class DistStor /** 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) {} }; @@ -1368,6 +1388,12 @@ class DistStor { const Params *params = safe_cast(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; @@ -1468,6 +1494,10 @@ class SampleStor void prepare(Info *info, DistData &data) { + const Params *params = safe_cast(info->storageParams); + + assert(params->type == Deviation); + data.type = params->type; data.sum = sum; data.squares = squares; data.samples = samples; @@ -1540,6 +1570,10 @@ class AvgSampleStor void prepare(Info *info, DistData &data) { + const Params *params = safe_cast(info->storageParams); + + assert(params->type == Deviation); + data.type = params->type; data.sum = sum; data.squares = squares; data.samples = curTick; -- cgit v1.2.3