52 std::string Info::separatorString =
"::";
70 InfoAccess::setInfo(
Info *info)
73 panic(
"shouldn't register stat twice!");
80 statsMap().insert(make_pair(
this, info));
81 assert(result.second &&
"this should never fail");
88 info()->storageParams = params;
94 info()->flags.set(
init);
100 MapType::const_iterator
i =
statsMap().find(
this);
106 InfoAccess::info()
const
108 MapType::const_iterator
i =
statsMap().find(
this);
113 StorageParams::~StorageParams()
124 int Info::id_count = 0;
129 : flags(
none), precision(-1), prereq(0), storageParams(NULL)
149 while (item != vec.end()) {
153 string::const_iterator
c = item->begin();
156 if (!isalpha(*c) && *c !=
'_')
160 while (++c != item->end()) {
161 if (!isalnum(*c) && *c !=
'_')
175 panic(
"invalid stat name '%s'", name);
178 nameMap().insert(make_pair(name,
this));
180 Info *other = p.first->second;
181 bool result = p.second;
186 panic(
"same statistic name used twice! name=%s\n", other->
name);
195 const string &name1 = stat1->
name;
196 const string &name2 = stat2->
name;
204 size_type last = min(v1.size(), v2.size()) - 1;
207 return v1[
i] < v2[
i];
210 if (v1[last] == v2[last])
211 return v1.size() < v2.size();
213 return v1[last] < v2[last];
223 cprintf(
"this is stat number %d\n",
id);
225 panic(
"Not all stats have been initialized.\n"
226 "You may need to add <ParentClass>::regStats() to a"
227 " new SimObject's regStats() function.");
232 panic(
"all printable stats must be named");
280 int top_half = zero + (size - zero + 1) / 2;
281 int bottom_half = (size -
zero) / 2;
284 int low_pair = zero - 1;
285 for (
int i = zero - 1;
i >= bottom_half;
i--) {
287 if (low_pair - 1 >= 0)
291 assert(low_pair == 0 || low_pair == -1 || low_pair == -2);
293 for (
int i = bottom_half - 1;
i >= 0;
i--)
297 int high_pair =
zero;
298 for (
int i = zero;
i < top_half;
i++) {
300 if (high_pair + 1 < size)
304 assert(high_pair == size || high_pair == size + 1);
306 for (
int i = top_half;
i <
size;
i++)
318 int half = (size + 1) / 2;
322 for (
int i = size - 1;
i >= half; --
i) {
329 for (
int i = half - 1;
i >= 0;
i--)
340 int half = (size + 1) / 2;
343 for (
int i = 0;
i < half;
i++) {
349 assert(pair == size || pair == size + 1);
351 for (
int i = half;
i <
size;
i++)
361 int b_size = hs->
size();
362 assert(
size() == b_size);
375 for (uint32_t
i = 0;
i < b_size;
i++)
393 assert(!
root &&
"Can't change formulas");
428 vec =
root->result();
511 fatal(
"Stats are already enabled");
522 fatal(
"No registered Stats::dump handler");
531 fatal(
"No registered Stats::reset handler");
double Result
All results are doubles.
Counter samples
The number of samples.
std::string name
The name of the stat.
static int id_count
A unique stat ID for each stat in the simulator.
void enable()
Enable the stat for use.
void processDumpQueue()
Process all the callbacks in the dump callbacks queue.
std::vector< std::string > subdescs
std::vector< std::string > subdescs
const std::string & name()
void process()
process all callbacks
Counter max_bucket
The maximum value to track.
virtual size_type size() const =0
VCounter cvec
Counter for each bucket.
virtual void enable()
Enable the stat for use.
std::vector< std::string > subnames
Names and descriptions of subfields.
void(* Handler)()
Register reset and dump handlers.
list< Info * > & statsList()
std::vector< std::string > y_subnames
Counter logs
The sum of logarithm of each sample, used to compute geometric mean.
void enable()
Enable the stat for use.
Counter squares
The sum of squares.
Counter min_bucket
The minimum value to track.
std::vector< std::string > subnames
Names and descriptions of subfields.
Declaration of Statistics objects.
double Counter
All counters are of 64-bit values.
bool zero() const
Returns true if any calls to sample have been made.
void add(Callback *callback)
Add a callback to the end of the queue.
Templatized storage and interface for a histogram stat.
static bool less(Info *stat1, Info *stat2)
Checks if the first stat's name is alphabetically less than the second.
Counter sum
The current sum.
std::shared_ptr< Node > NodePtr
Shared pointer to a function Node.
Flags flags
The formatting flags.
void registerResetCallback(Callback *cb)
Register a callback that should be called whenever statistics are reset.
virtual size_type size() const =0
size_type size() const
Return the number of buckets in this distribution.
void setName(const std::string &name)
Set the name of this statistic.
const FlagsType display
Print this stat.
const FlagsType none
Nothing extra to print.
std::map< const void *, Info * > MapType
void enable()
Enable the stat for use.
Counter bucket_size
The number of entries in each bucket.
Helper class to construct formula node trees.
std::vector< std::string > subdescs
void registerDumpCallback(Callback *cb)
Register a callback that should be called whenever statistics are about to be dumped.
void setInit()
Save Storage class parameters if any.
void processResetQueue()
Process all the callbacks in the reset callbacks queue.
NodePtr getNodePtr() const
Makde gcc < 4.6.3 happy and explicitly get the underlying node.
bool validateStatName(const string &name)
void tokenize(vector< string > &v, const string &s, char token, bool ignore)
void dump()
Dump all statistics data to the registered outputs.
std::map< std::string, Info * > NameMapType
void registerHandlers(Handler reset_handler, Handler dump_handler)
const FlagsType init
This Stat is Initialized.
std::vector< std::string > subnames
Names and descriptions of subfields.
void cprintf(const char *format, const Args &...args)