Go to the documentation of this file.
16 inline double max(
double a,
double b)
17 {
if (a > b)
return a;
return b; }
41 int stat1Type = -1, stat2Type = -1;
42 std::vector<const statistics *> stat1;
43 std::vector<const statistics *> stat2;
51 while (stat1.size() > stat2.size())
53 while (stat2.size() > stat1.size())
60 printf(
"Collecting stats for %s\n", stats->
LookupOwnerID(currOwner));
62 if (s->
owner != currOwner)
74 else if (stat2Type == -1)
85 while (stat1.size() > stat2.size())
87 while (stat2.size() > stat1.size())
90 double sum1=0.0, sum2=0.0;
92 for (
unsigned int x = 0; x < stat1.size(); x++)
95 sum1 += (double)stat1[x]->value.lval;
97 sum1 += stat1[x]->value.fval;
100 sum2 += (double)stat2[x]->value.lval;
102 sum2 += stat2[x]->value.fval;
120 printf(
"Measuring ratio between %s and %s as collected by %s\n",
124 printf(
"%d stats collected\n%s average %1.4e\n%s average %1.4e\n",
127 (
double)sum2/stat2.size());
128 printf(
"Ratios:\n%s / %s: %1.4e\n%s / %s: %1.4e\n",
147 for (
int x = 0; x < (int)stats->
GetNumStats(); x++)
163 double maxval = -9999999999.9;
168 for (
int x = 0; x < (int)stats->
GetNumStats(); x++)
184 long unsigned count = 0;
189 for (
int x = 0; x < (int)stats->
GetNumStats(); x++)
204 for (
int x = 0; x < (int)stats->
GetNumStats(); x++)
229 for (
int x = 0; x < (int)stats->
GetNumStats(); x++)
243 return sqrt(stdev/count);
const char * LookupOwnerID(int id) const
Given a owner ID, return the text description.
int LookupCategory(const char *category) const
Given a category, look up the ID.
double stdevStatEntries(StatCollection *stats, const char *category, const char *owner)
void ClearAllStats()
Remove all stat entries from the collection.
void setupAverageRatio(StatCollection *stats, char *stat1, char *stat2)
Setup the stats so a ratio between two stats for each unit can be properly measured.
double SumStatEntries(StatCollection *stats, const char *category, const char *owner)
Sum the values of all stat entries for the same (category, owner).
void ClearFilters()
Clear any filters being used for stat entry.
const char * lookupCategoryID(int id) const
Given a category ID, return the text description.
const statistics * GetStatNum(int which) const
Return the nth stat which has been collected.
double max(double a, double b)
The StatCollection class is for collecting stats across different parts of the simulation.
double maxStatEntries(StatCollection *stats, const char *category, const char *owner)
double averageStatEntries(StatCollection *stats, const char *category, const char *owner)
void AddIncludeFilter(const char *category)
int GetNumStats() const
The number of stats collected so far.
long unsigned countStatEntries(StatCollection *stats, const char *category, const char *owner)
Count the number of state instances in the stat collection.
void measureAverageRatio(StatCollection *stats)
Measures the ration between the two stats set-up from setupAverageRatio.
int LookupOwner(const char *owner) const
Given an owner, look up the ID.