stats: Try to make the names of things more intuitive.
Basically, this means renaming several things called data to info, which is information about the statistics. Things that are named data now are actual data stored for the statistic.
This commit is contained in:
parent
bcb7e70178
commit
fb74987c52
9 changed files with 424 additions and 410 deletions
|
@ -48,65 +48,59 @@ using namespace std;
|
||||||
|
|
||||||
namespace Stats {
|
namespace Stats {
|
||||||
|
|
||||||
StatData *
|
Info *
|
||||||
DataAccess::find() const
|
InfoAccess::find() const
|
||||||
{
|
{
|
||||||
return Database::find(const_cast<void *>((const void *)this));
|
return Database::find(const_cast<void *>((const void *)this));
|
||||||
}
|
}
|
||||||
|
|
||||||
const StatData *
|
const Info *
|
||||||
getStatData(const void *stat)
|
getInfo(const void *stat)
|
||||||
{
|
{
|
||||||
return Database::find(const_cast<void *>(stat));
|
return Database::find(const_cast<void *>(stat));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DataAccess::map(StatData *data)
|
InfoAccess::setInfo(Info *info)
|
||||||
{
|
{
|
||||||
Database::regStat(this, data);
|
Database::regStat(this, info);
|
||||||
}
|
|
||||||
|
|
||||||
StatData *
|
|
||||||
DataAccess::statData()
|
|
||||||
{
|
|
||||||
StatData *ptr = find();
|
|
||||||
assert(ptr);
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
const StatData *
|
|
||||||
DataAccess::statData() const
|
|
||||||
{
|
|
||||||
const StatData *ptr = find();
|
|
||||||
assert(ptr);
|
|
||||||
return ptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DataAccess::setInit()
|
InfoAccess::setInit()
|
||||||
{
|
{
|
||||||
statData()->flags |= init;
|
info()->flags |= init;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
Info *
|
||||||
DataAccess::setPrint()
|
InfoAccess::info()
|
||||||
{
|
{
|
||||||
Database::regPrint(this);
|
Info *info = find();
|
||||||
|
assert(info);
|
||||||
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
StatData::StatData()
|
const Info *
|
||||||
|
InfoAccess::info() const
|
||||||
|
{
|
||||||
|
const Info *info = find();
|
||||||
|
assert(info);
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info::Info()
|
||||||
: flags(none), precision(-1), prereq(0)
|
: flags(none), precision(-1), prereq(0)
|
||||||
{
|
{
|
||||||
static int count = 0;
|
static int count = 0;
|
||||||
id = count++;
|
id = count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
StatData::~StatData()
|
Info::~Info()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
StatData::less(StatData *stat1, StatData *stat2)
|
Info::less(Info *stat1, Info *stat2)
|
||||||
{
|
{
|
||||||
const string &name1 = stat1->name;
|
const string &name1 = stat1->name;
|
||||||
const string &name2 = stat2->name;
|
const string &name2 = stat2->name;
|
||||||
|
@ -132,7 +126,7 @@ StatData::less(StatData *stat1, StatData *stat2)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
StatData::baseCheck() const
|
Info::baseCheck() const
|
||||||
{
|
{
|
||||||
if (!(flags & init)) {
|
if (!(flags & init)) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -190,7 +184,7 @@ FormulaBase::zero() const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FormulaBase::update(StatData *)
|
FormulaBase::update(Info *)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,20 +232,20 @@ check()
|
||||||
|
|
||||||
iter_t i, end = Database::stats().end();
|
iter_t i, end = Database::stats().end();
|
||||||
for (i = Database::stats().begin(); i != end; ++i) {
|
for (i = Database::stats().begin(); i != end; ++i) {
|
||||||
StatData *data = *i;
|
Info *info = *i;
|
||||||
assert(data);
|
assert(info);
|
||||||
if (!data->check() || !data->baseCheck())
|
if (!info->check() || !info->baseCheck())
|
||||||
panic("stat check failed for %s\n", data->name);
|
panic("stat check failed for %s\n", info->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t j = 0;
|
off_t j = 0;
|
||||||
for (i = Database::stats().begin(); i != end; ++i) {
|
for (i = Database::stats().begin(); i != end; ++i) {
|
||||||
StatData *data = *i;
|
Info *info = *i;
|
||||||
if (!(data->flags & print))
|
if (!(info->flags & print))
|
||||||
data->name = "__Stat" + to_string(j++);
|
info->name = "__Stat" + to_string(j++);
|
||||||
}
|
}
|
||||||
|
|
||||||
Database::stats().sort(StatData::less);
|
Database::stats().sort(Info::less);
|
||||||
|
|
||||||
if (i == end)
|
if (i == end)
|
||||||
return;
|
return;
|
||||||
|
@ -275,8 +269,8 @@ reset()
|
||||||
Database::stat_list_t::iterator i = Database::stats().begin();
|
Database::stat_list_t::iterator i = Database::stats().begin();
|
||||||
Database::stat_list_t::iterator end = Database::stats().end();
|
Database::stat_list_t::iterator end = Database::stats().end();
|
||||||
while (i != end) {
|
while (i != end) {
|
||||||
StatData *data = *i;
|
Info *info = *i;
|
||||||
data->reset();
|
info->reset();
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* Authors: Nathan Binkert
|
* Authors: Nathan Binkert
|
||||||
* Erik Hallnor
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @file
|
/** @file
|
||||||
|
@ -60,6 +59,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "base/cast.hh"
|
||||||
#include "base/cprintf.hh"
|
#include "base/cprintf.hh"
|
||||||
#include "base/intmath.hh"
|
#include "base/intmath.hh"
|
||||||
#include "base/refcnt.hh"
|
#include "base/refcnt.hh"
|
||||||
|
@ -85,8 +85,9 @@ typedef std::numeric_limits<Counter> CounterLimits;
|
||||||
// Statistics Framework Base classes
|
// Statistics Framework Base classes
|
||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
struct StatData
|
class Info
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
/** The name of the stat. */
|
/** The name of the stat. */
|
||||||
std::string name;
|
std::string name;
|
||||||
/** The description of the stat. */
|
/** The description of the stat. */
|
||||||
|
@ -96,15 +97,16 @@ struct StatData
|
||||||
/** The display precision. */
|
/** The display precision. */
|
||||||
int precision;
|
int precision;
|
||||||
/** A pointer to a prerequisite Stat. */
|
/** A pointer to a prerequisite Stat. */
|
||||||
const StatData *prereq;
|
const Info *prereq;
|
||||||
/**
|
/**
|
||||||
* A unique stat ID for each stat in the simulator.
|
* A unique stat ID for each stat in the simulator.
|
||||||
* Can be used externally for lookups as well as for debugging.
|
* Can be used externally for lookups as well as for debugging.
|
||||||
*/
|
*/
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
StatData();
|
public:
|
||||||
virtual ~StatData();
|
Info();
|
||||||
|
virtual ~Info();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the corresponding stat to the default state.
|
* Reset the corresponding stat to the default state.
|
||||||
|
@ -138,10 +140,10 @@ struct StatData
|
||||||
* @param stat2 The second stat.
|
* @param stat2 The second stat.
|
||||||
* @return stat1's name is alphabetically before stat2's
|
* @return stat1's name is alphabetically before stat2's
|
||||||
*/
|
*/
|
||||||
static bool less(StatData *stat1, StatData *stat2);
|
static bool less(Info *stat1, Info *stat2);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ScalarData : public StatData
|
class ScalarInfoBase : public Info
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual Counter value() const = 0;
|
virtual Counter value() const = 0;
|
||||||
|
@ -151,13 +153,13 @@ class ScalarData : public StatData
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Stat>
|
template <class Stat>
|
||||||
class ScalarStatData : public ScalarData
|
class ScalarInfo : public ScalarInfoBase
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
Stat &s;
|
Stat &s;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScalarStatData(Stat &stat) : s(stat) {}
|
ScalarInfo(Stat &stat) : s(stat) {}
|
||||||
|
|
||||||
virtual bool check() const { return s.check(); }
|
virtual bool check() const { return s.check(); }
|
||||||
virtual Counter value() const { return s.value(); }
|
virtual Counter value() const { return s.value(); }
|
||||||
|
@ -167,12 +169,14 @@ class ScalarStatData : public ScalarData
|
||||||
virtual bool zero() const { return s.zero(); }
|
virtual bool zero() const { return s.zero(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VectorData : public StatData
|
class VectorInfoBase : public Info
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
/** Names and descriptions of subfields. */
|
/** Names and descriptions of subfields. */
|
||||||
mutable std::vector<std::string> subnames;
|
mutable std::vector<std::string> subnames;
|
||||||
mutable std::vector<std::string> subdescs;
|
mutable std::vector<std::string> subdescs;
|
||||||
|
|
||||||
|
public:
|
||||||
virtual size_type size() const = 0;
|
virtual size_type size() const = 0;
|
||||||
virtual const VCounter &value() const = 0;
|
virtual const VCounter &value() const = 0;
|
||||||
virtual const VResult &result() const = 0;
|
virtual const VResult &result() const = 0;
|
||||||
|
@ -193,7 +197,7 @@ struct VectorData : public StatData
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Stat>
|
template <class Stat>
|
||||||
class VectorStatData : public VectorData
|
class VectorInfo : public VectorInfoBase
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
Stat &s;
|
Stat &s;
|
||||||
|
@ -201,7 +205,7 @@ class VectorStatData : public VectorData
|
||||||
mutable VResult rvec;
|
mutable VResult rvec;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VectorStatData(Stat &stat) : s(stat) {}
|
VectorInfo(Stat &stat) : s(stat) {}
|
||||||
|
|
||||||
virtual bool check() const { return s.check(); }
|
virtual bool check() const { return s.check(); }
|
||||||
virtual bool zero() const { return s.zero(); }
|
virtual bool zero() const { return s.zero(); }
|
||||||
|
@ -234,7 +238,7 @@ class VectorStatData : public VectorData
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DistDataData
|
struct DistData
|
||||||
{
|
{
|
||||||
Counter min_val;
|
Counter min_val;
|
||||||
Counter max_val;
|
Counter max_val;
|
||||||
|
@ -252,20 +256,21 @@ struct DistDataData
|
||||||
bool fancy;
|
bool fancy;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DistData : public StatData
|
class DistInfoBase : public Info
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
/** Local storage for the entry values, used for printing. */
|
/** Local storage for the entry values, used for printing. */
|
||||||
DistDataData data;
|
DistData data;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Stat>
|
template <class Stat>
|
||||||
class DistStatData : public DistData
|
class DistInfo : public DistInfoBase
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
Stat &s;
|
Stat &s;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DistStatData(Stat &stat) : s(stat) {}
|
DistInfo(Stat &stat) : s(stat) {}
|
||||||
|
|
||||||
virtual bool check() const { return s.check(); }
|
virtual bool check() const { return s.check(); }
|
||||||
virtual void reset() { s.reset(); }
|
virtual void reset() { s.reset(); }
|
||||||
|
@ -279,17 +284,20 @@ class DistStatData : public DistData
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VectorDistData : public StatData
|
class VectorDistInfoBase : public Info
|
||||||
{
|
{
|
||||||
std::vector<DistDataData> data;
|
public:
|
||||||
|
std::vector<DistData> data;
|
||||||
|
|
||||||
/** Names and descriptions of subfields. */
|
/** Names and descriptions of subfields. */
|
||||||
mutable std::vector<std::string> subnames;
|
mutable std::vector<std::string> subnames;
|
||||||
mutable std::vector<std::string> subdescs;
|
mutable std::vector<std::string> subdescs;
|
||||||
|
|
||||||
|
protected:
|
||||||
/** Local storage for the entry values, used for printing. */
|
/** Local storage for the entry values, used for printing. */
|
||||||
mutable VResult rvec;
|
mutable VResult rvec;
|
||||||
|
|
||||||
|
public:
|
||||||
virtual size_type size() const = 0;
|
virtual size_type size() const = 0;
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -305,13 +313,13 @@ struct VectorDistData : public StatData
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Stat>
|
template <class Stat>
|
||||||
class VectorDistStatData : public VectorDistData
|
class VectorDistInfo : public VectorDistInfoBase
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
Stat &s;
|
Stat &s;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VectorDistStatData(Stat &stat) : s(stat) {}
|
VectorDistInfo(Stat &stat) : s(stat) {}
|
||||||
|
|
||||||
virtual bool check() const { return s.check(); }
|
virtual bool check() const { return s.check(); }
|
||||||
virtual void reset() { s.reset(); }
|
virtual void reset() { s.reset(); }
|
||||||
|
@ -327,8 +335,9 @@ class VectorDistStatData : public VectorDistData
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Vector2dData : public StatData
|
class Vector2dInfoBase : public Info
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
/** Names and descriptions of subfields. */
|
/** Names and descriptions of subfields. */
|
||||||
std::vector<std::string> subnames;
|
std::vector<std::string> subnames;
|
||||||
std::vector<std::string> subdescs;
|
std::vector<std::string> subdescs;
|
||||||
|
@ -339,6 +348,7 @@ struct Vector2dData : public StatData
|
||||||
mutable size_type x;
|
mutable size_type x;
|
||||||
mutable size_type y;
|
mutable size_type y;
|
||||||
|
|
||||||
|
public:
|
||||||
void
|
void
|
||||||
update()
|
update()
|
||||||
{
|
{
|
||||||
|
@ -348,13 +358,13 @@ struct Vector2dData : public StatData
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Stat>
|
template <class Stat>
|
||||||
class Vector2dStatData : public Vector2dData
|
class Vector2dInfo : public Vector2dInfoBase
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
Stat &s;
|
Stat &s;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Vector2dStatData(Stat &stat) : s(stat) {}
|
Vector2dInfo(Stat &stat) : s(stat) {}
|
||||||
|
|
||||||
virtual bool check() const { return s.check(); }
|
virtual bool check() const { return s.check(); }
|
||||||
virtual void reset() { s.reset(); }
|
virtual void reset() { s.reset(); }
|
||||||
|
@ -369,43 +379,42 @@ class Vector2dStatData : public Vector2dData
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class DataAccess
|
class InfoAccess
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
StatData *find() const;
|
Info *find() const;
|
||||||
void map(StatData *data);
|
/** Set up an info class for this statistic */
|
||||||
|
void setInfo(Info *info);
|
||||||
StatData *statData();
|
/** Save Storage class parameters if any */
|
||||||
const StatData *statData() const;
|
|
||||||
|
|
||||||
void setInit();
|
void setInit();
|
||||||
void setPrint();
|
|
||||||
|
Info *info();
|
||||||
|
const Info *info() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Parent, class Child, template <class> class Data>
|
template <class Parent, class Child, template <class> class Info>
|
||||||
class Wrap : public Child
|
class Wrap : public Child
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
typedef Parent ParentType;
|
||||||
|
typedef Child ChildType;
|
||||||
|
typedef Info<Child> InfoType;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Parent &self() { return *reinterpret_cast<Parent *>(this); }
|
Parent &self() { return *reinterpret_cast<Parent *>(this); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Data<Child> *
|
InfoType *
|
||||||
statData()
|
info()
|
||||||
{
|
{
|
||||||
StatData *__data = DataAccess::statData();
|
return safe_cast<InfoType *>(InfoAccess::info());
|
||||||
Data<Child> *ptr = dynamic_cast<Data<Child> *>(__data);
|
|
||||||
assert(ptr);
|
|
||||||
return ptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const Data<Child> *
|
const InfoType *
|
||||||
statData() const
|
info() const
|
||||||
{
|
{
|
||||||
const StatData *__data = DataAccess::statData();
|
return safe_cast<const InfoType *>(InfoAccess::info());
|
||||||
const Data<Child> *ptr = dynamic_cast<const Data<Child> *>(__data);
|
|
||||||
assert(ptr);
|
|
||||||
return ptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -422,7 +431,7 @@ class Wrap : public Child
|
||||||
public:
|
public:
|
||||||
Wrap()
|
Wrap()
|
||||||
{
|
{
|
||||||
this->map(new Data<Child>(*this));
|
this->setInfo(new InfoType(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -433,9 +442,9 @@ class Wrap : public Child
|
||||||
Parent &
|
Parent &
|
||||||
name(const std::string &_name)
|
name(const std::string &_name)
|
||||||
{
|
{
|
||||||
Data<Child> *data = this->statData();
|
InfoType *info = this->info();
|
||||||
data->name = _name;
|
info->name = _name;
|
||||||
this->setPrint();
|
info->flags |= print;
|
||||||
return this->self();
|
return this->self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,7 +457,7 @@ class Wrap : public Child
|
||||||
Parent &
|
Parent &
|
||||||
desc(const std::string &_desc)
|
desc(const std::string &_desc)
|
||||||
{
|
{
|
||||||
this->statData()->desc = _desc;
|
this->info()->desc = _desc;
|
||||||
return this->self();
|
return this->self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,7 +469,7 @@ class Wrap : public Child
|
||||||
Parent &
|
Parent &
|
||||||
precision(int _precision)
|
precision(int _precision)
|
||||||
{
|
{
|
||||||
this->statData()->precision = _precision;
|
this->info()->precision = _precision;
|
||||||
return this->self();
|
return this->self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,7 +481,7 @@ class Wrap : public Child
|
||||||
Parent &
|
Parent &
|
||||||
flags(StatFlags _flags)
|
flags(StatFlags _flags)
|
||||||
{
|
{
|
||||||
this->statData()->flags |= _flags;
|
this->info()->flags |= _flags;
|
||||||
return this->self();
|
return this->self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,14 +495,19 @@ class Wrap : public Child
|
||||||
Parent &
|
Parent &
|
||||||
prereq(const Stat &prereq)
|
prereq(const Stat &prereq)
|
||||||
{
|
{
|
||||||
this->statData()->prereq = prereq.statData();
|
this->info()->prereq = prereq.info();
|
||||||
return this->self();
|
return this->self();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Parent, class Child, template <class Child> class Data>
|
template <class Parent, class Child, template <class Child> class Info>
|
||||||
class WrapVec : public Wrap<Parent, Child, Data>
|
class WrapVec : public Wrap<Parent, Child, Info>
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
typedef Parent ParentType;
|
||||||
|
typedef Child ChildType;
|
||||||
|
typedef Info<Child> InfoType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// The following functions are specific to vectors. If you use them
|
// The following functions are specific to vectors. If you use them
|
||||||
// in a non vector context, you will get a nice compiler error!
|
// in a non vector context, you will get a nice compiler error!
|
||||||
|
@ -508,7 +522,7 @@ class WrapVec : public Wrap<Parent, Child, Data>
|
||||||
Parent &
|
Parent &
|
||||||
subname(off_type index, const std::string &name)
|
subname(off_type index, const std::string &name)
|
||||||
{
|
{
|
||||||
std::vector<std::string> &subn = this->statData()->subnames;
|
std::vector<std::string> &subn = this->info()->subnames;
|
||||||
if (subn.size() <= index)
|
if (subn.size() <= index)
|
||||||
subn.resize(index + 1);
|
subn.resize(index + 1);
|
||||||
subn[index] = name;
|
subn[index] = name;
|
||||||
|
@ -525,7 +539,7 @@ class WrapVec : public Wrap<Parent, Child, Data>
|
||||||
Parent &
|
Parent &
|
||||||
subdesc(off_type index, const std::string &desc)
|
subdesc(off_type index, const std::string &desc)
|
||||||
{
|
{
|
||||||
std::vector<std::string> &subd = this->statData()->subdescs;
|
std::vector<std::string> &subd = this->info()->subdescs;
|
||||||
if (subd.size() <= index)
|
if (subd.size() <= index)
|
||||||
subd.resize(index + 1);
|
subd.resize(index + 1);
|
||||||
subd[index] = desc;
|
subd[index] = desc;
|
||||||
|
@ -535,9 +549,14 @@ class WrapVec : public Wrap<Parent, Child, Data>
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Parent, class Child, template <class Child> class Data>
|
template <class Parent, class Child, template <class Child> class Info>
|
||||||
class WrapVec2d : public WrapVec<Parent, Child, Data>
|
class WrapVec2d : public WrapVec<Parent, Child, Info>
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
typedef Parent ParentType;
|
||||||
|
typedef Child ChildType;
|
||||||
|
typedef Info<Child> InfoType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @warning This makes the assumption that if you're gonna subnames a 2d
|
* @warning This makes the assumption that if you're gonna subnames a 2d
|
||||||
|
@ -546,20 +565,20 @@ class WrapVec2d : public WrapVec<Parent, Child, Data>
|
||||||
Parent &
|
Parent &
|
||||||
ysubnames(const char **names)
|
ysubnames(const char **names)
|
||||||
{
|
{
|
||||||
Data<Child> *data = this->statData();
|
InfoType *info = this->info();
|
||||||
data->y_subnames.resize(this->y);
|
info->y_subnames.resize(this->y);
|
||||||
for (off_type i = 0; i < this->y; ++i)
|
for (off_type i = 0; i < this->y; ++i)
|
||||||
data->y_subnames[i] = names[i];
|
info->y_subnames[i] = names[i];
|
||||||
return this->self();
|
return this->self();
|
||||||
}
|
}
|
||||||
|
|
||||||
Parent &
|
Parent &
|
||||||
ysubname(off_type index, const std::string subname)
|
ysubname(off_type index, const std::string subname)
|
||||||
{
|
{
|
||||||
Data<Child> *data = this->statData();
|
InfoType *info = this->info();
|
||||||
assert(index < this->y);
|
assert(index < this->y);
|
||||||
data->y_subnames.resize(this->y);
|
info->y_subnames.resize(this->y);
|
||||||
data->y_subnames[index] = subname.c_str();
|
info->y_subnames[index] = subname.c_str();
|
||||||
return this->self();
|
return this->self();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -573,7 +592,7 @@ class WrapVec2d : public WrapVec<Parent, Child, Data>
|
||||||
/**
|
/**
|
||||||
* Templatized storage and interface for a simple scalar stat.
|
* Templatized storage and interface for a simple scalar stat.
|
||||||
*/
|
*/
|
||||||
struct StatStor
|
class StatStor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** The paramaters for this storage type, none for a scalar. */
|
/** The paramaters for this storage type, none for a scalar. */
|
||||||
|
@ -638,7 +657,7 @@ struct StatStor
|
||||||
* being watched. This is good for keeping track of residencies in structures
|
* being watched. This is good for keeping track of residencies in structures
|
||||||
* among other things.
|
* among other things.
|
||||||
*/
|
*/
|
||||||
struct AvgStor
|
class AvgStor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** The paramaters for this storage type */
|
/** The paramaters for this storage type */
|
||||||
|
@ -665,7 +684,8 @@ struct AvgStor
|
||||||
* @param p The parameters for this storage.
|
* @param p The parameters for this storage.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
set(Counter val, Params &p) {
|
set(Counter val, Params &p)
|
||||||
|
{
|
||||||
total += current * (curTick - last);
|
total += current * (curTick - last);
|
||||||
last = curTick;
|
last = curTick;
|
||||||
current = val;
|
current = val;
|
||||||
|
@ -726,7 +746,7 @@ struct AvgStor
|
||||||
* Storage template.
|
* Storage template.
|
||||||
*/
|
*/
|
||||||
template <class Stor>
|
template <class Stor>
|
||||||
class ScalarBase : public DataAccess
|
class ScalarBase : public InfoAccess
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef Stor Storage;
|
typedef Stor Storage;
|
||||||
|
@ -851,7 +871,7 @@ class ScalarBase : public DataAccess
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ProxyData : public ScalarData
|
class ProxyInfo : public ScalarInfoBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void visit(Visit &visitor) { visitor.visit(*this); }
|
virtual void visit(Visit &visitor) { visitor.visit(*this); }
|
||||||
|
@ -863,7 +883,7 @@ class ProxyData : public ScalarData
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
class ValueProxy : public ProxyData
|
class ValueProxy : public ProxyInfo
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
T *scalar;
|
T *scalar;
|
||||||
|
@ -876,7 +896,7 @@ class ValueProxy : public ProxyData
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
class FunctorProxy : public ProxyData
|
class FunctorProxy : public ProxyInfo
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
T *functor;
|
T *functor;
|
||||||
|
@ -888,10 +908,10 @@ class FunctorProxy : public ProxyData
|
||||||
virtual Result total() const { return (*functor)(); }
|
virtual Result total() const { return (*functor)(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class ValueBase : public DataAccess
|
class ValueBase : public InfoAccess
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
ProxyData *proxy;
|
ProxyInfo *proxy;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ValueBase() : proxy(NULL) { }
|
ValueBase() : proxy(NULL) { }
|
||||||
|
@ -983,7 +1003,8 @@ class ScalarProxy
|
||||||
* @return A reference to this proxy.
|
* @return A reference to this proxy.
|
||||||
*/
|
*/
|
||||||
const ScalarProxy &
|
const ScalarProxy &
|
||||||
operator=(const ScalarProxy &sp) {
|
operator=(const ScalarProxy &sp)
|
||||||
|
{
|
||||||
stat = sp.stat;
|
stat = sp.stat;
|
||||||
index = sp.index;
|
index = sp.index;
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -1058,7 +1079,7 @@ class ScalarProxy
|
||||||
std::string
|
std::string
|
||||||
str() const
|
str() const
|
||||||
{
|
{
|
||||||
return csprintf("%s[%d]", stat->statData()->name, index);
|
return csprintf("%s[%d]", stat->info()->name, index);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1067,7 +1088,7 @@ class ScalarProxy
|
||||||
* Storage class. @sa ScalarBase
|
* Storage class. @sa ScalarBase
|
||||||
*/
|
*/
|
||||||
template <class Stor>
|
template <class Stor>
|
||||||
class VectorBase : public DataAccess
|
class VectorBase : public InfoAccess
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef Stor Storage;
|
typedef Stor Storage;
|
||||||
|
@ -1207,7 +1228,7 @@ class VectorBase : public DataAccess
|
||||||
return Proxy(this, index);
|
return Proxy(this, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(StatData *data) {}
|
void update(Info *data) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Stat>
|
template <class Stat>
|
||||||
|
@ -1292,7 +1313,7 @@ class VectorProxy
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Stor>
|
template <class Stor>
|
||||||
class Vector2dBase : public DataAccess
|
class Vector2dBase : public InfoAccess
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef Stor Storage;
|
typedef Stor Storage;
|
||||||
|
@ -1318,12 +1339,12 @@ class Vector2dBase : public DataAccess
|
||||||
assert(_x > 0 && _y > 0 && "sizes must be positive!");
|
assert(_x > 0 && _y > 0 && "sizes must be positive!");
|
||||||
assert(!storage && "already initialized");
|
assert(!storage && "already initialized");
|
||||||
|
|
||||||
Vector2dData *statdata = dynamic_cast<Vector2dData *>(find());
|
Vector2dInfoBase *info = dynamic_cast<Vector2dInfoBase *>(find());
|
||||||
|
|
||||||
x = _x;
|
x = _x;
|
||||||
y = _y;
|
y = _y;
|
||||||
statdata->x = _x;
|
info->x = _x;
|
||||||
statdata->y = _y;
|
info->y = _y;
|
||||||
_size = x * y;
|
_size = x * y;
|
||||||
|
|
||||||
char *ptr = new char[_size * sizeof(Storage)];
|
char *ptr = new char[_size * sizeof(Storage)];
|
||||||
|
@ -1351,12 +1372,12 @@ class Vector2dBase : public DataAccess
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
update(Vector2dData *newdata)
|
update(Vector2dInfoBase *newinfo)
|
||||||
{
|
{
|
||||||
size_type size = this->size();
|
size_type size = this->size();
|
||||||
newdata->cvec.resize(size);
|
newinfo->cvec.resize(size);
|
||||||
for (off_type i = 0; i < size; ++i)
|
for (off_type i = 0; i < size; ++i)
|
||||||
newdata->cvec[i] = data(i)->value(params);
|
newinfo->cvec[i] = data(i)->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ysubname(off_type i) const { return (*this->y_subnames)[i]; }
|
std::string ysubname(off_type i) const { return (*this->y_subnames)[i]; }
|
||||||
|
@ -1414,7 +1435,7 @@ class Vector2dBase : public DataAccess
|
||||||
/**
|
/**
|
||||||
* Templatized storage and interface for a distrbution stat.
|
* Templatized storage and interface for a distrbution stat.
|
||||||
*/
|
*/
|
||||||
struct DistStor
|
class DistStor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** The parameters for a distribution stat. */
|
/** The parameters for a distribution stat. */
|
||||||
|
@ -1507,7 +1528,7 @@ struct DistStor
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
update(DistDataData *data, const Params ¶ms)
|
update(DistData *data, const Params ¶ms)
|
||||||
{
|
{
|
||||||
data->min = params.min;
|
data->min = params.min;
|
||||||
data->max = params.max;
|
data->max = params.max;
|
||||||
|
@ -1552,7 +1573,7 @@ struct 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.
|
||||||
*/
|
*/
|
||||||
struct FancyStor
|
class FancyStor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@ -1595,7 +1616,7 @@ struct FancyStor
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
update(DistDataData *data, const Params ¶ms)
|
update(DistData *data, const Params ¶ms)
|
||||||
{
|
{
|
||||||
data->sum = sum;
|
data->sum = sum;
|
||||||
data->squares = squares;
|
data->squares = squares;
|
||||||
|
@ -1630,7 +1651,7 @@ struct FancyStor
|
||||||
* Templatized storage for distribution that calculates per tick mean and
|
* Templatized storage for distribution that calculates per tick mean and
|
||||||
* variance.
|
* variance.
|
||||||
*/
|
*/
|
||||||
struct AvgFancy
|
class AvgFancy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** No parameters for this storage. */
|
/** No parameters for this storage. */
|
||||||
|
@ -1665,7 +1686,7 @@ struct AvgFancy
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
update(DistDataData *data, const Params ¶ms)
|
update(DistData *data, const Params ¶ms)
|
||||||
{
|
{
|
||||||
data->sum = sum;
|
data->sum = sum;
|
||||||
data->squares = squares;
|
data->squares = squares;
|
||||||
|
@ -1700,7 +1721,7 @@ struct AvgFancy
|
||||||
* determined by the Storage template. @sa ScalarBase
|
* determined by the Storage template. @sa ScalarBase
|
||||||
*/
|
*/
|
||||||
template <class Stor>
|
template <class Stor>
|
||||||
class DistBase : public DataAccess
|
class DistBase : public InfoAccess
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef Stor Storage;
|
typedef Stor Storage;
|
||||||
|
@ -1766,7 +1787,7 @@ class DistBase : public DataAccess
|
||||||
bool zero() const { return data()->zero(params); }
|
bool zero() const { return data()->zero(params); }
|
||||||
|
|
||||||
void
|
void
|
||||||
update(DistData *base)
|
update(DistInfoBase *base)
|
||||||
{
|
{
|
||||||
base->data.fancy = Storage::fancy;
|
base->data.fancy = Storage::fancy;
|
||||||
data()->update(&(base->data), params);
|
data()->update(&(base->data), params);
|
||||||
|
@ -1792,7 +1813,7 @@ template <class Stat>
|
||||||
class DistProxy;
|
class DistProxy;
|
||||||
|
|
||||||
template <class Stor>
|
template <class Stor>
|
||||||
class VectorDistBase : public DataAccess
|
class VectorDistBase : public InfoAccess
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef Stor Storage;
|
typedef Stor Storage;
|
||||||
|
@ -1886,7 +1907,7 @@ class VectorDistBase : public DataAccess
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
update(VectorDistData *base)
|
update(VectorDistInfoBase *base)
|
||||||
{
|
{
|
||||||
size_type size = this->size();
|
size_type size = this->size();
|
||||||
base->data.resize(size);
|
base->data.resize(size);
|
||||||
|
@ -2011,11 +2032,11 @@ typedef RefCountingPtr<Node> NodePtr;
|
||||||
class ScalarStatNode : public Node
|
class ScalarStatNode : public Node
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
const ScalarData *data;
|
const ScalarInfoBase *data;
|
||||||
mutable VResult vresult;
|
mutable VResult vresult;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScalarStatNode(const ScalarData *d) : data(d), vresult(1) {}
|
ScalarStatNode(const ScalarInfoBase *d) : data(d), vresult(1) {}
|
||||||
|
|
||||||
virtual const VResult &
|
virtual const VResult &
|
||||||
result() const
|
result() const
|
||||||
|
@ -2078,10 +2099,10 @@ class ScalarProxyNode : public Node
|
||||||
class VectorStatNode : public Node
|
class VectorStatNode : public Node
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
const VectorData *data;
|
const VectorInfoBase *data;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VectorStatNode(const VectorData *d) : data(d) { }
|
VectorStatNode(const VectorInfoBase *d) : data(d) { }
|
||||||
virtual const VResult &result() const { return data->result(); }
|
virtual const VResult &result() const { return data->result(); }
|
||||||
virtual Result total() const { return data->total(); };
|
virtual Result total() const { return data->total(); };
|
||||||
|
|
||||||
|
@ -2364,7 +2385,7 @@ class SumNode : public Node
|
||||||
* @sa Stat, ScalarBase, StatStor
|
* @sa Stat, ScalarBase, StatStor
|
||||||
*/
|
*/
|
||||||
template<int N = 0>
|
template<int N = 0>
|
||||||
class Scalar : public Wrap<Scalar<N>, ScalarBase<StatStor>, ScalarStatData>
|
class Scalar : public Wrap<Scalar<N>, ScalarBase<StatStor>, ScalarInfo>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** The base implementation. */
|
/** The base implementation. */
|
||||||
|
@ -2384,7 +2405,7 @@ class Scalar : public Wrap<Scalar<N>, ScalarBase<StatStor>, ScalarStatData>
|
||||||
void operator=(const U &v) { Base::operator=(v); }
|
void operator=(const U &v) { Base::operator=(v); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class Value : public Wrap<Value, ValueBase, ScalarStatData>
|
class Value : public Wrap<Value, ValueBase, ScalarInfo>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** The base implementation. */
|
/** The base implementation. */
|
||||||
|
@ -2412,7 +2433,7 @@ class Value : public Wrap<Value, ValueBase, ScalarStatData>
|
||||||
* @sa Stat, ScalarBase, AvgStor
|
* @sa Stat, ScalarBase, AvgStor
|
||||||
*/
|
*/
|
||||||
template<int N = 0>
|
template<int N = 0>
|
||||||
class Average : public Wrap<Average<N>, ScalarBase<AvgStor>, ScalarStatData>
|
class Average : public Wrap<Average<N>, ScalarBase<AvgStor>, ScalarInfo>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** The base implementation. */
|
/** The base implementation. */
|
||||||
|
@ -2441,7 +2462,7 @@ class Average : public Wrap<Average<N>, ScalarBase<AvgStor>, ScalarStatData>
|
||||||
* @sa Stat, VectorBase, StatStor
|
* @sa Stat, VectorBase, StatStor
|
||||||
*/
|
*/
|
||||||
template<int N = 0>
|
template<int N = 0>
|
||||||
class Vector : public WrapVec<Vector<N>, VectorBase<StatStor>, VectorStatData>
|
class Vector : public WrapVec<Vector<N>, VectorBase<StatStor>, VectorInfo>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** The base implementation. */
|
/** The base implementation. */
|
||||||
|
@ -2466,7 +2487,7 @@ class Vector : public WrapVec<Vector<N>, VectorBase<StatStor>, VectorStatData>
|
||||||
*/
|
*/
|
||||||
template<int N = 0>
|
template<int N = 0>
|
||||||
class AverageVector
|
class AverageVector
|
||||||
: public WrapVec<AverageVector<N>, VectorBase<AvgStor>, VectorStatData>
|
: public WrapVec<AverageVector<N>, VectorBase<AvgStor>, VectorInfo>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@ -2488,7 +2509,7 @@ class AverageVector
|
||||||
*/
|
*/
|
||||||
template<int N = 0>
|
template<int N = 0>
|
||||||
class Vector2d
|
class Vector2d
|
||||||
: public WrapVec2d<Vector2d<N>, Vector2dBase<StatStor>, Vector2dStatData>
|
: public WrapVec2d<Vector2d<N>, Vector2dBase<StatStor>, Vector2dInfo>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Vector2d &
|
Vector2d &
|
||||||
|
@ -2505,7 +2526,7 @@ class Vector2d
|
||||||
*/
|
*/
|
||||||
template<int N = 0>
|
template<int N = 0>
|
||||||
class Distribution
|
class Distribution
|
||||||
: public Wrap<Distribution<N>, DistBase<DistStor>, DistStatData>
|
: public Wrap<Distribution<N>, DistBase<DistStor>, DistInfo>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** Base implementation. */
|
/** Base implementation. */
|
||||||
|
@ -2539,7 +2560,7 @@ class Distribution
|
||||||
*/
|
*/
|
||||||
template<int N = 0>
|
template<int N = 0>
|
||||||
class StandardDeviation
|
class StandardDeviation
|
||||||
: public Wrap<StandardDeviation<N>, DistBase<FancyStor>, DistStatData>
|
: public Wrap<StandardDeviation<N>, DistBase<FancyStor>, DistInfo>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** The base implementation */
|
/** The base implementation */
|
||||||
|
@ -2563,7 +2584,7 @@ class StandardDeviation
|
||||||
*/
|
*/
|
||||||
template<int N = 0>
|
template<int N = 0>
|
||||||
class AverageDeviation
|
class AverageDeviation
|
||||||
: public Wrap<AverageDeviation<N>, DistBase<AvgFancy>, DistStatData>
|
: public Wrap<AverageDeviation<N>, DistBase<AvgFancy>, DistInfo>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** The base implementation */
|
/** The base implementation */
|
||||||
|
@ -2589,7 +2610,7 @@ template<int N = 0>
|
||||||
class VectorDistribution
|
class VectorDistribution
|
||||||
: public WrapVec<VectorDistribution<N>,
|
: public WrapVec<VectorDistribution<N>,
|
||||||
VectorDistBase<DistStor>,
|
VectorDistBase<DistStor>,
|
||||||
VectorDistStatData>
|
VectorDistInfo>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** The base implementation */
|
/** The base implementation */
|
||||||
|
@ -2626,7 +2647,7 @@ template<int N = 0>
|
||||||
class VectorStandardDeviation
|
class VectorStandardDeviation
|
||||||
: public WrapVec<VectorStandardDeviation<N>,
|
: public WrapVec<VectorStandardDeviation<N>,
|
||||||
VectorDistBase<FancyStor>,
|
VectorDistBase<FancyStor>,
|
||||||
VectorDistStatData>
|
VectorDistInfo>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** The base implementation */
|
/** The base implementation */
|
||||||
|
@ -2656,7 +2677,7 @@ template<int N = 0>
|
||||||
class VectorAverageDeviation
|
class VectorAverageDeviation
|
||||||
: public WrapVec<VectorAverageDeviation<N>,
|
: public WrapVec<VectorAverageDeviation<N>,
|
||||||
VectorDistBase<AvgFancy>,
|
VectorDistBase<AvgFancy>,
|
||||||
VectorDistStatData>
|
VectorDistInfo>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** The base implementation */
|
/** The base implementation */
|
||||||
|
@ -2683,7 +2704,7 @@ class VectorAverageDeviation
|
||||||
* stored as a tree of Nodes that represent the equation to calculate.
|
* stored as a tree of Nodes that represent the equation to calculate.
|
||||||
* @sa Stat, ScalarStat, VectorStat, Node, Temp
|
* @sa Stat, ScalarStat, VectorStat, Node, Temp
|
||||||
*/
|
*/
|
||||||
class FormulaBase : public DataAccess
|
class FormulaBase : public InfoAccess
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
/** The root of the tree which represents the Formula */
|
/** The root of the tree which represents the Formula */
|
||||||
|
@ -2732,12 +2753,12 @@ class FormulaBase : public DataAccess
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void update(StatData *);
|
void update(Info *);
|
||||||
|
|
||||||
std::string str() const;
|
std::string str() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FormulaData : public VectorData
|
class FormulaInfoBase : public VectorInfoBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual std::string str() const = 0;
|
virtual std::string str() const = 0;
|
||||||
|
@ -2745,7 +2766,7 @@ class FormulaData : public VectorData
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Stat>
|
template <class Stat>
|
||||||
class FormulaStatData : public FormulaData
|
class FormulaInfo : public FormulaInfoBase
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
Stat &s;
|
Stat &s;
|
||||||
|
@ -2753,7 +2774,7 @@ class FormulaStatData : public FormulaData
|
||||||
mutable VCounter cvec;
|
mutable VCounter cvec;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FormulaStatData(Stat &stat) : s(stat) {}
|
FormulaInfo(Stat &stat) : s(stat) {}
|
||||||
|
|
||||||
virtual bool zero() const { return s.zero(); }
|
virtual bool zero() const { return s.zero(); }
|
||||||
virtual void reset() { s.reset(); }
|
virtual void reset() { s.reset(); }
|
||||||
|
@ -2784,7 +2805,7 @@ class Temp;
|
||||||
class Formula
|
class Formula
|
||||||
: public WrapVec<Formula,
|
: public WrapVec<Formula,
|
||||||
FormulaBase,
|
FormulaBase,
|
||||||
FormulaStatData>
|
FormulaInfo>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@ -2861,7 +2882,7 @@ class Temp
|
||||||
*/
|
*/
|
||||||
template <int N>
|
template <int N>
|
||||||
Temp(const Scalar<N> &s)
|
Temp(const Scalar<N> &s)
|
||||||
: node(new ScalarStatNode(s.statData()))
|
: node(new ScalarStatNode(s.info()))
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2869,7 +2890,7 @@ class Temp
|
||||||
* @param s The ScalarStat to place in a node.
|
* @param s The ScalarStat to place in a node.
|
||||||
*/
|
*/
|
||||||
Temp(const Value &s)
|
Temp(const Value &s)
|
||||||
: node(new ScalarStatNode(s.statData()))
|
: node(new ScalarStatNode(s.info()))
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2878,7 +2899,7 @@ class Temp
|
||||||
*/
|
*/
|
||||||
template <int N>
|
template <int N>
|
||||||
Temp(const Average<N> &s)
|
Temp(const Average<N> &s)
|
||||||
: node(new ScalarStatNode(s.statData()))
|
: node(new ScalarStatNode(s.info()))
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2887,7 +2908,7 @@ class Temp
|
||||||
*/
|
*/
|
||||||
template <int N>
|
template <int N>
|
||||||
Temp(const Vector<N> &s)
|
Temp(const Vector<N> &s)
|
||||||
: node(new VectorStatNode(s.statData()))
|
: node(new VectorStatNode(s.info()))
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -503,11 +503,11 @@ MySql::configure()
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = stats().begin(); i != end; ++i) {
|
for (i = stats().begin(); i != end; ++i) {
|
||||||
StatData *data = *i;
|
Info *info = *i;
|
||||||
if (data->prereq) {
|
if (info->prereq) {
|
||||||
// update the prerequisite
|
// update the prerequisite
|
||||||
uint16_t stat_id = find(data->id);
|
uint16_t stat_id = find(info->id);
|
||||||
uint16_t prereq_id = find(data->prereq->id);
|
uint16_t prereq_id = find(info->prereq->id);
|
||||||
assert(stat_id && prereq_id);
|
assert(stat_id && prereq_id);
|
||||||
|
|
||||||
stringstream update;
|
stringstream update;
|
||||||
|
@ -528,153 +528,152 @@ MySql::configure()
|
||||||
configured = true;
|
configured = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
MySql::configure(const StatData &data, string type)
|
MySql::configure(const Info &info, string type)
|
||||||
{
|
{
|
||||||
stat.init();
|
stat.init();
|
||||||
stat.name = data.name;
|
stat.name = info.name;
|
||||||
stat.descr = data.desc;
|
stat.descr = info.desc;
|
||||||
stat.type = type;
|
stat.type = type;
|
||||||
stat.print = data.flags & print;
|
stat.print = info.flags & print;
|
||||||
stat.prec = data.precision;
|
stat.prec = info.precision;
|
||||||
stat.nozero = data.flags & nozero;
|
stat.nozero = info.flags & nozero;
|
||||||
stat.nonan = data.flags & nonan;
|
stat.nonan = info.flags & nonan;
|
||||||
stat.total = data.flags & total;
|
stat.total = info.flags & total;
|
||||||
stat.pdf = data.flags & pdf;
|
stat.pdf = info.flags & pdf;
|
||||||
stat.cdf = data.flags & cdf;
|
stat.cdf = info.flags & cdf;
|
||||||
|
|
||||||
return stat.print;
|
return stat.print;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MySql::configure(const ScalarData &data)
|
MySql::configure(const ScalarInfoBase &info)
|
||||||
{
|
{
|
||||||
if (!configure(data, "SCALAR"))
|
if (!configure(info, "SCALAR"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
insert(data.id, stat.setup(run));
|
insert(info.id, stat.setup(run));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MySql::configure(const VectorData &data)
|
MySql::configure(const VectorInfoBase &info)
|
||||||
{
|
{
|
||||||
if (!configure(data, "VECTOR"))
|
if (!configure(info, "VECTOR"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint16_t statid = stat.setup(run);
|
uint16_t statid = stat.setup(run);
|
||||||
|
|
||||||
if (!data.subnames.empty()) {
|
if (!info.subnames.empty()) {
|
||||||
InsertSubData subdata;
|
InsertSubData subdata;
|
||||||
subdata.stat = statid;
|
subdata.stat = statid;
|
||||||
subdata.y = 0;
|
subdata.y = 0;
|
||||||
for (off_type i = 0; i < data.subnames.size(); ++i) {
|
for (off_type i = 0; i < info.subnames.size(); ++i) {
|
||||||
subdata.x = i;
|
subdata.x = i;
|
||||||
subdata.name = data.subnames[i];
|
subdata.name = info.subnames[i];
|
||||||
subdata.descr = data.subdescs.empty() ? "" : data.subdescs[i];
|
subdata.descr = info.subdescs.empty() ? "" : info.subdescs[i];
|
||||||
|
|
||||||
if (!subdata.name.empty() || !subdata.descr.empty())
|
if (!subdata.name.empty() || !subdata.descr.empty())
|
||||||
subdata.setup(run);
|
subdata.setup(run);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
insert(data.id, statid);
|
insert(info.id, statid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MySql::configure(const DistData &data)
|
MySql::configure(const DistInfoBase &info)
|
||||||
{
|
{
|
||||||
if (!configure(data, "DIST"))
|
if (!configure(info, "DIST"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!data.data.fancy) {
|
if (!info.data.fancy) {
|
||||||
stat.size = data.data.size;
|
stat.size = info.data.size;
|
||||||
stat.min = data.data.min;
|
stat.min = info.data.min;
|
||||||
stat.max = data.data.max;
|
stat.max = info.data.max;
|
||||||
stat.bktsize = data.data.bucket_size;
|
stat.bktsize = info.data.bucket_size;
|
||||||
}
|
}
|
||||||
insert(data.id, stat.setup(run));
|
insert(info.id, stat.setup(run));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MySql::configure(const VectorDistData &data)
|
MySql::configure(const VectorDistInfoBase &info)
|
||||||
{
|
{
|
||||||
if (!configure(data, "VECTORDIST"))
|
if (!configure(info, "VECTORDIST"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!data.data[0].fancy) {
|
if (!info.data[0].fancy) {
|
||||||
stat.size = data.data[0].size;
|
stat.size = info.data[0].size;
|
||||||
stat.min = data.data[0].min;
|
stat.min = info.data[0].min;
|
||||||
stat.max = data.data[0].max;
|
stat.max = info.data[0].max;
|
||||||
stat.bktsize = data.data[0].bucket_size;
|
stat.bktsize = info.data[0].bucket_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t statid = stat.setup(run);
|
uint16_t statid = stat.setup(run);
|
||||||
|
|
||||||
if (!data.subnames.empty()) {
|
if (!info.subnames.empty()) {
|
||||||
InsertSubData subdata;
|
InsertSubData subdata;
|
||||||
subdata.stat = statid;
|
subdata.stat = statid;
|
||||||
subdata.y = 0;
|
subdata.y = 0;
|
||||||
for (off_type i = 0; i < data.subnames.size(); ++i) {
|
for (off_type i = 0; i < info.subnames.size(); ++i) {
|
||||||
subdata.x = i;
|
subdata.x = i;
|
||||||
subdata.name = data.subnames[i];
|
subdata.name = info.subnames[i];
|
||||||
subdata.descr = data.subdescs.empty() ? "" : data.subdescs[i];
|
subdata.descr = info.subdescs.empty() ? "" : info.subdescs[i];
|
||||||
if (!subdata.name.empty() || !subdata.descr.empty())
|
if (!subdata.name.empty() || !subdata.descr.empty())
|
||||||
subdata.setup(run);
|
subdata.setup(run);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
insert(data.id, statid);
|
insert(info.id, statid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MySql::configure(const Vector2dData &data)
|
MySql::configure(const Vector2dInfoBase &info)
|
||||||
{
|
{
|
||||||
if (!configure(data, "VECTOR2D"))
|
if (!configure(info, "VECTOR2D"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint16_t statid = stat.setup(run);
|
uint16_t statid = stat.setup(run);
|
||||||
|
|
||||||
if (!data.subnames.empty()) {
|
if (!info.subnames.empty()) {
|
||||||
InsertSubData subdata;
|
InsertSubData subdata;
|
||||||
subdata.stat = statid;
|
subdata.stat = statid;
|
||||||
subdata.y = -1;
|
subdata.y = -1;
|
||||||
for (off_type i = 0; i < data.subnames.size(); ++i) {
|
for (off_type i = 0; i < info.subnames.size(); ++i) {
|
||||||
subdata.x = i;
|
subdata.x = i;
|
||||||
subdata.name = data.subnames[i];
|
subdata.name = info.subnames[i];
|
||||||
subdata.descr = data.subdescs.empty() ? "" : data.subdescs[i];
|
subdata.descr = info.subdescs.empty() ? "" : info.subdescs[i];
|
||||||
if (!subdata.name.empty() || !subdata.descr.empty())
|
if (!subdata.name.empty() || !subdata.descr.empty())
|
||||||
subdata.setup(run);
|
subdata.setup(run);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data.y_subnames.empty()) {
|
if (!info.y_subnames.empty()) {
|
||||||
InsertSubData subdata;
|
InsertSubData subdata;
|
||||||
subdata.stat = statid;
|
subdata.stat = statid;
|
||||||
subdata.x = -1;
|
subdata.x = -1;
|
||||||
subdata.descr = "";
|
subdata.descr = "";
|
||||||
for (off_type i = 0; i < data.y_subnames.size(); ++i) {
|
for (off_type i = 0; i < info.y_subnames.size(); ++i) {
|
||||||
subdata.y = i;
|
subdata.y = i;
|
||||||
subdata.name = data.y_subnames[i];
|
subdata.name = info.y_subnames[i];
|
||||||
if (!subdata.name.empty())
|
if (!subdata.name.empty())
|
||||||
subdata.setup(run);
|
subdata.setup(run);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
insert(data.id, statid);
|
insert(info.id, statid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MySql::configure(const FormulaData &data)
|
MySql::configure(const FormulaInfoBase &info)
|
||||||
{
|
{
|
||||||
MySQL::Connection &mysql = run->conn();
|
MySQL::Connection &mysql = run->conn();
|
||||||
assert(mysql.connected());
|
assert(mysql.connected());
|
||||||
|
|
||||||
configure(data, "FORMULA");
|
configure(info, "FORMULA");
|
||||||
insert(data.id, stat.setup(run));
|
insert(info.id, stat.setup(run));
|
||||||
|
|
||||||
uint16_t stat = find(data.id);
|
uint16_t stat = find(info.id);
|
||||||
string formula = data.str();
|
string formula = info.str();
|
||||||
|
|
||||||
stringstream insert_formula;
|
stringstream insert_formula;
|
||||||
ccprintf(insert_formula,
|
ccprintf(insert_formula,
|
||||||
|
@ -720,7 +719,7 @@ MySql::output()
|
||||||
|
|
||||||
Database::stat_list_t::const_iterator i, end = Database::stats().end();
|
Database::stat_list_t::const_iterator i, end = Database::stats().end();
|
||||||
for (i = Database::stats().begin(); i != end; ++i) {
|
for (i = Database::stats().begin(); i != end; ++i) {
|
||||||
StatData *stat = *i;
|
Info *stat = *i;
|
||||||
stat->visit(*this);
|
stat->visit(*this);
|
||||||
if (mysql.commit())
|
if (mysql.commit())
|
||||||
panic("could not commit transaction\n%s\n", mysql.error);
|
panic("could not commit transaction\n%s\n", mysql.error);
|
||||||
|
@ -735,32 +734,31 @@ MySql::event(const std::string &event)
|
||||||
newevent.insert(event);
|
newevent.insert(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MySql::output(const ScalarData &data)
|
MySql::output(const ScalarInfoBase &info)
|
||||||
{
|
{
|
||||||
if (!(data.flags & print))
|
if (!(info.flags & print))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
newdata.stat = find(data.id);
|
newdata.stat = find(info.id);
|
||||||
newdata.x = 0;
|
newdata.x = 0;
|
||||||
newdata.y = 0;
|
newdata.y = 0;
|
||||||
newdata.data = data.value();
|
newdata.data = info.value();
|
||||||
|
|
||||||
newdata.insert();
|
newdata.insert();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MySql::output(const VectorData &data)
|
MySql::output(const VectorInfoBase &info)
|
||||||
{
|
{
|
||||||
if (!(data.flags & print))
|
if (!(info.flags & print))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
newdata.stat = find(data.id);
|
newdata.stat = find(info.id);
|
||||||
newdata.y = 0;
|
newdata.y = 0;
|
||||||
|
|
||||||
const VCounter &cvec = data.value();
|
const VCounter &cvec = info.value();
|
||||||
size_type size = data.size();
|
size_type size = info.size();
|
||||||
for (off_type x = 0; x < size; x++) {
|
for (off_type x = 0; x < size; x++) {
|
||||||
newdata.x = x;
|
newdata.x = x;
|
||||||
newdata.data = cvec[x];
|
newdata.data = cvec[x];
|
||||||
|
@ -769,7 +767,7 @@ MySql::output(const VectorData &data)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MySql::output(const DistDataData &data)
|
MySql::output(const DistData &data)
|
||||||
{
|
{
|
||||||
const int db_sum = -1;
|
const int db_sum = -1;
|
||||||
const int db_squares = -2;
|
const int db_squares = -2;
|
||||||
|
@ -817,54 +815,53 @@ MySql::output(const DistDataData &data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MySql::output(const DistData &data)
|
MySql::output(const DistInfoBase &info)
|
||||||
{
|
{
|
||||||
if (!(data.flags & print))
|
if (!(info.flags & print))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
newdata.stat = find(data.id);
|
newdata.stat = find(info.id);
|
||||||
newdata.y = 0;
|
newdata.y = 0;
|
||||||
output(data.data);
|
output(info.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MySql::output(const VectorDistData &data)
|
MySql::output(const VectorDistInfoBase &info)
|
||||||
{
|
{
|
||||||
if (!(data.flags & print))
|
if (!(info.flags & print))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
newdata.stat = find(data.id);
|
newdata.stat = find(info.id);
|
||||||
|
|
||||||
size_type size = data.data.size();
|
size_type size = info.data.size();
|
||||||
for (off_type y = 0; y < size; ++y) {
|
for (off_type y = 0; y < size; ++y) {
|
||||||
newdata.y = y;
|
newdata.y = y;
|
||||||
output(data.data[y]);
|
output(info.data[y]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MySql::output(const Vector2dData &data)
|
MySql::output(const Vector2dInfoBase &info)
|
||||||
{
|
{
|
||||||
if (!(data.flags & print))
|
if (!(info.flags & print))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
newdata.stat = find(data.id);
|
newdata.stat = find(info.id);
|
||||||
|
|
||||||
off_type index = 0;
|
off_type index = 0;
|
||||||
for (off_type x = 0; x < data.x; x++) {
|
for (off_type x = 0; x < info.x; x++) {
|
||||||
newdata.x = x;
|
newdata.x = x;
|
||||||
for (off_type y = 0; y < data.y; y++) {
|
for (off_type y = 0; y < info.y; y++) {
|
||||||
newdata.y = y;
|
newdata.y = y;
|
||||||
newdata.data = data.cvec[index++];
|
newdata.data = info.cvec[index++];
|
||||||
newdata.insert();
|
newdata.insert();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MySql::output(const FormulaData &data)
|
MySql::output(const FormulaInfoBase &info)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -872,60 +869,60 @@ MySql::output(const FormulaData &data)
|
||||||
* Implement the visitor
|
* Implement the visitor
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
MySql::visit(const ScalarData &data)
|
MySql::visit(const ScalarInfoBase &info)
|
||||||
{
|
{
|
||||||
if (!configured)
|
if (!configured)
|
||||||
configure(data);
|
configure(info);
|
||||||
else
|
else
|
||||||
output(data);
|
output(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MySql::visit(const VectorData &data)
|
MySql::visit(const VectorInfoBase &info)
|
||||||
{
|
{
|
||||||
if (!configured)
|
if (!configured)
|
||||||
configure(data);
|
configure(info);
|
||||||
else
|
else
|
||||||
output(data);
|
output(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MySql::visit(const DistData &data)
|
MySql::visit(const DistInfoBase &info)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
if (!configured)
|
if (!configured)
|
||||||
configure(data);
|
configure(info);
|
||||||
else
|
else
|
||||||
output(data);
|
output(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MySql::visit(const VectorDistData &data)
|
MySql::visit(const VectorDistInfoBase &info)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
if (!configured)
|
if (!configured)
|
||||||
configure(data);
|
configure(info);
|
||||||
else
|
else
|
||||||
output(data);
|
output(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MySql::visit(const Vector2dData &data)
|
MySql::visit(const Vector2dInfoBase &info)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
if (!configured)
|
if (!configured)
|
||||||
configure(data);
|
configure(info);
|
||||||
else
|
else
|
||||||
output(data);
|
output(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MySql::visit(const FormulaData &data)
|
MySql::visit(const FormulaInfoBase &info)
|
||||||
{
|
{
|
||||||
if (!configured)
|
if (!configured)
|
||||||
configure(data);
|
configure(info);
|
||||||
else
|
else
|
||||||
output(data);
|
output(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
namespace MySQL { class Connection; }
|
namespace MySQL { class Connection; }
|
||||||
namespace Stats {
|
namespace Stats {
|
||||||
|
|
||||||
class DistDataData;
|
class DistInfoBase;
|
||||||
class MySqlRun;
|
class MySqlRun;
|
||||||
|
|
||||||
struct SetupStat
|
struct SetupStat
|
||||||
|
@ -121,7 +121,7 @@ class MySql : public Output
|
||||||
SetupStat stat;
|
SetupStat stat;
|
||||||
InsertData newdata;
|
InsertData newdata;
|
||||||
InsertEvent newevent;
|
InsertEvent newevent;
|
||||||
std::list<FormulaData *> formulas;
|
std::list<FormulaInfoBase *> formulas;
|
||||||
bool configured;
|
bool configured;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -155,12 +155,12 @@ class MySql : public Output
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Implement Visit
|
// Implement Visit
|
||||||
virtual void visit(const ScalarData &data);
|
virtual void visit(const ScalarInfoBase &info);
|
||||||
virtual void visit(const VectorData &data);
|
virtual void visit(const VectorInfoBase &info);
|
||||||
virtual void visit(const DistData &data);
|
virtual void visit(const DistInfoBase &info);
|
||||||
virtual void visit(const VectorDistData &data);
|
virtual void visit(const VectorDistInfoBase &info);
|
||||||
virtual void visit(const Vector2dData &data);
|
virtual void visit(const Vector2dInfoBase &info);
|
||||||
virtual void visit(const FormulaData &data);
|
virtual void visit(const FormulaInfoBase &info);
|
||||||
|
|
||||||
// Implement Output
|
// Implement Output
|
||||||
virtual bool valid() const;
|
virtual bool valid() const;
|
||||||
|
@ -171,22 +171,22 @@ class MySql : public Output
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Output helper
|
// Output helper
|
||||||
void output(const DistDataData &data);
|
void output(const ScalarInfoBase &info);
|
||||||
void output(const ScalarData &data);
|
void output(const VectorInfoBase &info);
|
||||||
void output(const VectorData &data);
|
void output(const DistInfoBase &info);
|
||||||
|
void output(const VectorDistInfoBase &info);
|
||||||
|
void output(const Vector2dInfoBase &info);
|
||||||
|
void output(const FormulaInfoBase &info);
|
||||||
void output(const DistData &data);
|
void output(const DistData &data);
|
||||||
void output(const VectorDistData &data);
|
|
||||||
void output(const Vector2dData &data);
|
|
||||||
void output(const FormulaData &data);
|
|
||||||
|
|
||||||
void configure();
|
void configure();
|
||||||
bool configure(const StatData &data, std::string type);
|
bool configure(const Info &info, std::string type);
|
||||||
void configure(const ScalarData &data);
|
void configure(const ScalarInfoBase &info);
|
||||||
void configure(const VectorData &data);
|
void configure(const VectorInfoBase &info);
|
||||||
void configure(const DistData &data);
|
void configure(const DistInfoBase &info);
|
||||||
void configure(const VectorDistData &data);
|
void configure(const VectorDistInfoBase &info);
|
||||||
void configure(const Vector2dData &data);
|
void configure(const Vector2dInfoBase &info);
|
||||||
void configure(const FormulaData &data);
|
void configure(const FormulaInfoBase &info);
|
||||||
};
|
};
|
||||||
|
|
||||||
bool initMySQL(std::string host, std::string database, std::string user,
|
bool initMySQL(std::string host, std::string database, std::string user,
|
||||||
|
|
|
@ -38,7 +38,7 @@ using namespace std;
|
||||||
namespace Stats {
|
namespace Stats {
|
||||||
namespace Database {
|
namespace Database {
|
||||||
|
|
||||||
StatData *
|
Info *
|
||||||
find(void *stat)
|
find(void *stat)
|
||||||
{
|
{
|
||||||
stat_map_t::const_iterator i = map().find(stat);
|
stat_map_t::const_iterator i = map().find(stat);
|
||||||
|
@ -50,7 +50,7 @@ find(void *stat)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
regStat(void *stat, StatData *data)
|
regStat(void *stat, Info *data)
|
||||||
{
|
{
|
||||||
if (map().find(stat) != map().end())
|
if (map().find(stat) != map().end())
|
||||||
panic("shouldn't register stat twice!");
|
panic("shouldn't register stat twice!");
|
||||||
|
@ -68,7 +68,7 @@ regStat(void *stat, StatData *data)
|
||||||
void
|
void
|
||||||
regPrint(void *stat)
|
regPrint(void *stat)
|
||||||
{
|
{
|
||||||
StatData *data = find(stat);
|
Info *data = find(stat);
|
||||||
assert(data);
|
assert(data);
|
||||||
data->flags |= print;
|
data->flags |= print;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,12 +40,12 @@ class Python;
|
||||||
|
|
||||||
namespace Stats {
|
namespace Stats {
|
||||||
|
|
||||||
class StatData;
|
class Info;
|
||||||
|
|
||||||
namespace Database {
|
namespace Database {
|
||||||
|
|
||||||
typedef std::map<void *, StatData *> stat_map_t;
|
typedef std::map<void *, Info *> stat_map_t;
|
||||||
typedef std::list<StatData *> stat_list_t;
|
typedef std::list<Info *> stat_list_t;
|
||||||
|
|
||||||
// We wrap the database in a struct to make sure it is built in time.
|
// We wrap the database in a struct to make sure it is built in time.
|
||||||
struct TheDatabase
|
struct TheDatabase
|
||||||
|
@ -58,8 +58,8 @@ TheDatabase &db();
|
||||||
inline stat_map_t &map() { return db().map; }
|
inline stat_map_t &map() { return db().map; }
|
||||||
inline stat_list_t &stats() { return db().stats; }
|
inline stat_list_t &stats() { return db().stats; }
|
||||||
|
|
||||||
StatData *find(void *stat);
|
Info *find(void *stat);
|
||||||
void regStat(void *stat, StatData *data);
|
void regStat(void *stat, Info *data);
|
||||||
void regPrint(void *stat);
|
void regPrint(void *stat);
|
||||||
|
|
||||||
inline std::string name() { return "Statistics Database"; }
|
inline std::string name() { return "Statistics Database"; }
|
||||||
|
|
|
@ -143,12 +143,12 @@ Text::output()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Text::noOutput(const StatData &data)
|
Text::noOutput(const Info &info)
|
||||||
{
|
{
|
||||||
if (!(data.flags & print))
|
if (!(info.flags & print))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (data.prereq && data.prereq->zero())
|
if (info.prereq && info.prereq->zero())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -535,19 +535,19 @@ DistPrint::operator()(ostream &stream) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Text::visit(const ScalarData &data)
|
Text::visit(const ScalarInfoBase &info)
|
||||||
{
|
{
|
||||||
if (noOutput(data))
|
if (noOutput(info))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ScalarPrint print;
|
ScalarPrint print;
|
||||||
print.value = data.result();
|
print.value = info.result();
|
||||||
print.name = data.name;
|
print.name = info.name;
|
||||||
print.desc = data.desc;
|
print.desc = info.desc;
|
||||||
print.flags = data.flags;
|
print.flags = info.flags;
|
||||||
print.compat = compat;
|
print.compat = compat;
|
||||||
print.descriptions = descriptions;
|
print.descriptions = descriptions;
|
||||||
print.precision = data.precision;
|
print.precision = info.precision;
|
||||||
print.pdf = NAN;
|
print.pdf = NAN;
|
||||||
print.cdf = NAN;
|
print.cdf = NAN;
|
||||||
|
|
||||||
|
@ -555,32 +555,32 @@ Text::visit(const ScalarData &data)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Text::visit(const VectorData &data)
|
Text::visit(const VectorInfoBase &info)
|
||||||
{
|
{
|
||||||
if (noOutput(data))
|
if (noOutput(info))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
size_type size = data.size();
|
size_type size = info.size();
|
||||||
VectorPrint print;
|
VectorPrint print;
|
||||||
|
|
||||||
print.name = data.name;
|
print.name = info.name;
|
||||||
print.desc = data.desc;
|
print.desc = info.desc;
|
||||||
print.flags = data.flags;
|
print.flags = info.flags;
|
||||||
print.compat = compat;
|
print.compat = compat;
|
||||||
print.descriptions = descriptions;
|
print.descriptions = descriptions;
|
||||||
print.precision = data.precision;
|
print.precision = info.precision;
|
||||||
print.vec = data.result();
|
print.vec = info.result();
|
||||||
print.total = data.total();
|
print.total = info.total();
|
||||||
|
|
||||||
if (!data.subnames.empty()) {
|
if (!info.subnames.empty()) {
|
||||||
for (off_type i = 0; i < size; ++i) {
|
for (off_type i = 0; i < size; ++i) {
|
||||||
if (!data.subnames[i].empty()) {
|
if (!info.subnames[i].empty()) {
|
||||||
print.subnames = data.subnames;
|
print.subnames = info.subnames;
|
||||||
print.subnames.resize(size);
|
print.subnames.resize(size);
|
||||||
for (off_type i = 0; i < size; ++i) {
|
for (off_type i = 0; i < size; ++i) {
|
||||||
if (!data.subnames[i].empty() &&
|
if (!info.subnames[i].empty() &&
|
||||||
!data.subdescs[i].empty()) {
|
!info.subdescs[i].empty()) {
|
||||||
print.subdescs = data.subdescs;
|
print.subdescs = info.subdescs;
|
||||||
print.subdescs.resize(size);
|
print.subdescs.resize(size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -594,54 +594,54 @@ Text::visit(const VectorData &data)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Text::visit(const Vector2dData &data)
|
Text::visit(const Vector2dInfoBase &info)
|
||||||
{
|
{
|
||||||
if (noOutput(data))
|
if (noOutput(info))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool havesub = false;
|
bool havesub = false;
|
||||||
VectorPrint print;
|
VectorPrint print;
|
||||||
|
|
||||||
print.subnames = data.y_subnames;
|
print.subnames = info.y_subnames;
|
||||||
print.flags = data.flags;
|
print.flags = info.flags;
|
||||||
print.compat = compat;
|
print.compat = compat;
|
||||||
print.descriptions = descriptions;
|
print.descriptions = descriptions;
|
||||||
print.precision = data.precision;
|
print.precision = info.precision;
|
||||||
|
|
||||||
if (!data.subnames.empty()) {
|
if (!info.subnames.empty()) {
|
||||||
for (off_type i = 0; i < data.x; ++i)
|
for (off_type i = 0; i < info.x; ++i)
|
||||||
if (!data.subnames[i].empty())
|
if (!info.subnames[i].empty())
|
||||||
havesub = true;
|
havesub = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
VResult tot_vec(data.y);
|
VResult tot_vec(info.y);
|
||||||
Result super_total = 0.0;
|
Result super_total = 0.0;
|
||||||
for (off_type i = 0; i < data.x; ++i) {
|
for (off_type i = 0; i < info.x; ++i) {
|
||||||
if (havesub && (i >= data.subnames.size() || data.subnames[i].empty()))
|
if (havesub && (i >= info.subnames.size() || info.subnames[i].empty()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
off_type iy = i * data.y;
|
off_type iy = i * info.y;
|
||||||
VResult yvec(data.y);
|
VResult yvec(info.y);
|
||||||
|
|
||||||
Result total = 0.0;
|
Result total = 0.0;
|
||||||
for (off_type j = 0; j < data.y; ++j) {
|
for (off_type j = 0; j < info.y; ++j) {
|
||||||
yvec[j] = data.cvec[iy + j];
|
yvec[j] = info.cvec[iy + j];
|
||||||
tot_vec[j] += yvec[j];
|
tot_vec[j] += yvec[j];
|
||||||
total += yvec[j];
|
total += yvec[j];
|
||||||
super_total += yvec[j];
|
super_total += yvec[j];
|
||||||
}
|
}
|
||||||
|
|
||||||
print.name = data.name + "_" +
|
print.name = info.name + "_" +
|
||||||
(havesub ? data.subnames[i] : to_string(i));
|
(havesub ? info.subnames[i] : to_string(i));
|
||||||
print.desc = data.desc;
|
print.desc = info.desc;
|
||||||
print.vec = yvec;
|
print.vec = yvec;
|
||||||
print.total = total;
|
print.total = total;
|
||||||
print(*stream);
|
print(*stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((data.flags & ::Stats::total) && (data.x > 1)) {
|
if ((info.flags & ::Stats::total) && (info.x > 1)) {
|
||||||
print.name = data.name;
|
print.name = info.name;
|
||||||
print.desc = data.desc;
|
print.desc = info.desc;
|
||||||
print.vec = tot_vec;
|
print.vec = tot_vec;
|
||||||
print.total = super_total;
|
print.total = super_total;
|
||||||
print(*stream);
|
print(*stream);
|
||||||
|
@ -649,82 +649,84 @@ Text::visit(const Vector2dData &data)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Text::visit(const DistData &data)
|
Text::visit(const DistInfoBase &info)
|
||||||
{
|
{
|
||||||
if (noOutput(data))
|
if (noOutput(info))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DistPrint print;
|
DistPrint print;
|
||||||
|
|
||||||
print.name = data.name;
|
print.name = info.name;
|
||||||
print.desc = data.desc;
|
print.desc = info.desc;
|
||||||
print.flags = data.flags;
|
print.flags = info.flags;
|
||||||
print.compat = compat;
|
print.compat = compat;
|
||||||
print.descriptions = descriptions;
|
print.descriptions = descriptions;
|
||||||
print.precision = data.precision;
|
print.precision = info.precision;
|
||||||
|
|
||||||
print.min_val = data.data.min_val;
|
const DistData &data = info.data;
|
||||||
print.max_val = data.data.max_val;
|
|
||||||
print.underflow = data.data.underflow;
|
print.min_val = data.min_val;
|
||||||
print.overflow = data.data.overflow;
|
print.max_val = data.max_val;
|
||||||
print.vec.resize(data.data.cvec.size());
|
print.underflow = data.underflow;
|
||||||
|
print.overflow = data.overflow;
|
||||||
|
print.vec.resize(data.cvec.size());
|
||||||
for (off_type i = 0; i < print.vec.size(); ++i)
|
for (off_type i = 0; i < print.vec.size(); ++i)
|
||||||
print.vec[i] = (Result)data.data.cvec[i];
|
print.vec[i] = (Result)data.cvec[i];
|
||||||
print.sum = data.data.sum;
|
print.sum = data.sum;
|
||||||
print.squares = data.data.squares;
|
print.squares = data.squares;
|
||||||
print.samples = data.data.samples;
|
print.samples = data.samples;
|
||||||
|
|
||||||
print.min = data.data.min;
|
print.min = data.min;
|
||||||
print.max = data.data.max;
|
print.max = data.max;
|
||||||
print.bucket_size = data.data.bucket_size;
|
print.bucket_size = data.bucket_size;
|
||||||
print.size = data.data.size;
|
print.size = data.size;
|
||||||
print.fancy = data.data.fancy;
|
print.fancy = data.fancy;
|
||||||
|
|
||||||
print(*stream);
|
print(*stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Text::visit(const VectorDistData &data)
|
Text::visit(const VectorDistInfoBase &info)
|
||||||
{
|
{
|
||||||
if (noOutput(data))
|
if (noOutput(info))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (off_type i = 0; i < data.size(); ++i) {
|
for (off_type i = 0; i < info.size(); ++i) {
|
||||||
DistPrint print;
|
DistPrint print;
|
||||||
|
|
||||||
print.name = data.name + "_" +
|
print.name = info.name + "_" +
|
||||||
(data.subnames[i].empty() ? (to_string(i)) : data.subnames[i]);
|
(info.subnames[i].empty() ? (to_string(i)) : info.subnames[i]);
|
||||||
print.desc = data.subdescs[i].empty() ? data.desc : data.subdescs[i];
|
print.desc = info.subdescs[i].empty() ? info.desc : info.subdescs[i];
|
||||||
print.flags = data.flags;
|
print.flags = info.flags;
|
||||||
print.compat = compat;
|
print.compat = compat;
|
||||||
print.descriptions = descriptions;
|
print.descriptions = descriptions;
|
||||||
print.precision = data.precision;
|
print.precision = info.precision;
|
||||||
|
|
||||||
print.min_val = data.data[i].min_val;
|
print.min_val = info.data[i].min_val;
|
||||||
print.max_val = data.data[i].max_val;
|
print.max_val = info.data[i].max_val;
|
||||||
print.underflow = data.data[i].underflow;
|
print.underflow = info.data[i].underflow;
|
||||||
print.overflow = data.data[i].overflow;
|
print.overflow = info.data[i].overflow;
|
||||||
print.vec.resize(data.data[i].cvec.size());
|
print.vec.resize(info.data[i].cvec.size());
|
||||||
for (off_type j = 0; j < print.vec.size(); ++j)
|
for (off_type j = 0; j < print.vec.size(); ++j)
|
||||||
print.vec[j] = (Result)data.data[i].cvec[j];
|
print.vec[j] = (Result)info.data[i].cvec[j];
|
||||||
print.sum = data.data[i].sum;
|
print.sum = info.data[i].sum;
|
||||||
print.squares = data.data[i].squares;
|
print.squares = info.data[i].squares;
|
||||||
print.samples = data.data[i].samples;
|
print.samples = info.data[i].samples;
|
||||||
|
|
||||||
print.min = data.data[i].min;
|
print.min = info.data[i].min;
|
||||||
print.max = data.data[i].max;
|
print.max = info.data[i].max;
|
||||||
print.bucket_size = data.data[i].bucket_size;
|
print.bucket_size = info.data[i].bucket_size;
|
||||||
print.size = data.data[i].size;
|
print.size = info.data[i].size;
|
||||||
print.fancy = data.data[i].fancy;
|
print.fancy = info.data[i].fancy;
|
||||||
|
|
||||||
print(*stream);
|
print(*stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Text::visit(const FormulaData &data)
|
Text::visit(const FormulaInfoBase &info)
|
||||||
{
|
{
|
||||||
visit((const VectorData &)data);
|
visit((const VectorInfoBase &)info);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -46,7 +46,7 @@ class Text : public Output
|
||||||
std::ostream *stream;
|
std::ostream *stream;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool noOutput(const StatData &data);
|
bool noOutput(const Info &info);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool compat;
|
bool compat;
|
||||||
|
@ -62,12 +62,12 @@ class Text : public Output
|
||||||
void open(const std::string &file);
|
void open(const std::string &file);
|
||||||
|
|
||||||
// Implement Visit
|
// Implement Visit
|
||||||
virtual void visit(const ScalarData &data);
|
virtual void visit(const ScalarInfoBase &info);
|
||||||
virtual void visit(const VectorData &data);
|
virtual void visit(const VectorInfoBase &info);
|
||||||
virtual void visit(const DistData &data);
|
virtual void visit(const DistInfoBase &info);
|
||||||
virtual void visit(const VectorDistData &data);
|
virtual void visit(const VectorDistInfoBase &info);
|
||||||
virtual void visit(const Vector2dData &data);
|
virtual void visit(const Vector2dInfoBase &info);
|
||||||
virtual void visit(const FormulaData &data);
|
virtual void visit(const FormulaInfoBase &info);
|
||||||
|
|
||||||
// Implement Output
|
// Implement Output
|
||||||
virtual bool valid() const;
|
virtual bool valid() const;
|
||||||
|
|
|
@ -38,26 +38,26 @@
|
||||||
|
|
||||||
namespace Stats {
|
namespace Stats {
|
||||||
|
|
||||||
class StatData;
|
class Info;
|
||||||
class ScalarData;
|
class ScalarInfoBase;
|
||||||
class VectorData;
|
class VectorInfoBase;
|
||||||
class DistDataData;
|
class DistInfoBase;
|
||||||
class DistData;
|
class DistInfoBase;
|
||||||
class VectorDistData;
|
class VectorDistInfoBase;
|
||||||
class Vector2dData;
|
class Vector2dInfoBase;
|
||||||
class FormulaData;
|
class FormulaInfoBase;
|
||||||
|
|
||||||
struct Visit
|
struct Visit
|
||||||
{
|
{
|
||||||
Visit();
|
Visit();
|
||||||
virtual ~Visit();
|
virtual ~Visit();
|
||||||
|
|
||||||
virtual void visit(const ScalarData &data) = 0;
|
virtual void visit(const ScalarInfoBase &info) = 0;
|
||||||
virtual void visit(const VectorData &data) = 0;
|
virtual void visit(const VectorInfoBase &info) = 0;
|
||||||
virtual void visit(const DistData &data) = 0;
|
virtual void visit(const DistInfoBase &info) = 0;
|
||||||
virtual void visit(const VectorDistData &data) = 0;
|
virtual void visit(const VectorDistInfoBase &info) = 0;
|
||||||
virtual void visit(const Vector2dData &data) = 0;
|
virtual void visit(const Vector2dInfoBase &info) = 0;
|
||||||
virtual void visit(const FormulaData &data) = 0;
|
virtual void visit(const FormulaInfoBase &info) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* namespace Stats */ }
|
/* namespace Stats */ }
|
||||||
|
|
Loading…
Reference in a new issue