statistics.hh (5599:5bad83cddb8c) statistics.hh (5886:12431dc9a30a)
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 12 unchanged lines hidden (view full) ---

21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Nathan Binkert
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 12 unchanged lines hidden (view full) ---

21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Nathan Binkert
29 * Erik Hallnor
30 */
31
32/** @file
33 * Declaration of Statistics objects.
34 */
35
36/**
37* @todo

--- 17 unchanged lines hidden (view full) ---

55#endif
56#include <cmath>
57#include <functional>
58#include <iosfwd>
59#include <limits>
60#include <string>
61#include <vector>
62
29 */
30
31/** @file
32 * Declaration of Statistics objects.
33 */
34
35/**
36* @todo

--- 17 unchanged lines hidden (view full) ---

54#endif
55#include <cmath>
56#include <functional>
57#include <iosfwd>
58#include <limits>
59#include <string>
60#include <vector>
61
62#include "base/cast.hh"
63#include "base/cprintf.hh"
64#include "base/intmath.hh"
65#include "base/refcnt.hh"
66#include "base/str.hh"
67#include "base/stats/flags.hh"
68#include "base/stats/visit.hh"
69#include "base/stats/types.hh"
70#include "sim/host.hh"

--- 9 unchanged lines hidden (view full) ---

80typedef std::numeric_limits<Counter> CounterLimits;
81
82/* Contains the statistic implementation details */
83//////////////////////////////////////////////////////////////////////
84//
85// Statistics Framework Base classes
86//
87//////////////////////////////////////////////////////////////////////
63#include "base/cprintf.hh"
64#include "base/intmath.hh"
65#include "base/refcnt.hh"
66#include "base/str.hh"
67#include "base/stats/flags.hh"
68#include "base/stats/visit.hh"
69#include "base/stats/types.hh"
70#include "sim/host.hh"

--- 9 unchanged lines hidden (view full) ---

80typedef std::numeric_limits<Counter> CounterLimits;
81
82/* Contains the statistic implementation details */
83//////////////////////////////////////////////////////////////////////
84//
85// Statistics Framework Base classes
86//
87//////////////////////////////////////////////////////////////////////
88struct StatData
88class Info
89{
89{
90 public:
90 /** The name of the stat. */
91 std::string name;
92 /** The description of the stat. */
93 std::string desc;
94 /** The formatting flags. */
95 StatFlags flags;
96 /** The display precision. */
97 int precision;
98 /** A pointer to a prerequisite Stat. */
91 /** The name of the stat. */
92 std::string name;
93 /** The description of the stat. */
94 std::string desc;
95 /** The formatting flags. */
96 StatFlags flags;
97 /** The display precision. */
98 int precision;
99 /** A pointer to a prerequisite Stat. */
99 const StatData *prereq;
100 const Info *prereq;
100 /**
101 * A unique stat ID for each stat in the simulator.
102 * Can be used externally for lookups as well as for debugging.
103 */
104 int id;
105
101 /**
102 * A unique stat ID for each stat in the simulator.
103 * Can be used externally for lookups as well as for debugging.
104 */
105 int id;
106
106 StatData();
107 virtual ~StatData();
107 public:
108 Info();
109 virtual ~Info();
108
109 /**
110 * Reset the corresponding stat to the default state.
111 */
112 virtual void reset() = 0;
113
114 /**
115 * @return true if this stat has a value and satisfies its

--- 17 unchanged lines hidden (view full) ---

133 /**
134 * Checks if the first stat's name is alphabetically less than the second.
135 * This function breaks names up at periods and considers each subname
136 * separately.
137 * @param stat1 The first stat.
138 * @param stat2 The second stat.
139 * @return stat1's name is alphabetically before stat2's
140 */
110
111 /**
112 * Reset the corresponding stat to the default state.
113 */
114 virtual void reset() = 0;
115
116 /**
117 * @return true if this stat has a value and satisfies its

--- 17 unchanged lines hidden (view full) ---

135 /**
136 * Checks if the first stat's name is alphabetically less than the second.
137 * This function breaks names up at periods and considers each subname
138 * separately.
139 * @param stat1 The first stat.
140 * @param stat2 The second stat.
141 * @return stat1's name is alphabetically before stat2's
142 */
141 static bool less(StatData *stat1, StatData *stat2);
143 static bool less(Info *stat1, Info *stat2);
142};
143
144};
145
144class ScalarData : public StatData
146class ScalarInfoBase : public Info
145{
146 public:
147 virtual Counter value() const = 0;
148 virtual Result result() const = 0;
149 virtual Result total() const = 0;
150 virtual void visit(Visit &visitor) { visitor.visit(*this); }
151};
152
153template <class Stat>
147{
148 public:
149 virtual Counter value() const = 0;
150 virtual Result result() const = 0;
151 virtual Result total() const = 0;
152 virtual void visit(Visit &visitor) { visitor.visit(*this); }
153};
154
155template <class Stat>
154class ScalarStatData : public ScalarData
156class ScalarInfo : public ScalarInfoBase
155{
156 protected:
157 Stat &s;
158
159 public:
157{
158 protected:
159 Stat &s;
160
161 public:
160 ScalarStatData(Stat &stat) : s(stat) {}
162 ScalarInfo(Stat &stat) : s(stat) {}
161
162 virtual bool check() const { return s.check(); }
163 virtual Counter value() const { return s.value(); }
164 virtual Result result() const { return s.result(); }
165 virtual Result total() const { return s.total(); }
166 virtual void reset() { s.reset(); }
167 virtual bool zero() const { return s.zero(); }
168};
169
163
164 virtual bool check() const { return s.check(); }
165 virtual Counter value() const { return s.value(); }
166 virtual Result result() const { return s.result(); }
167 virtual Result total() const { return s.total(); }
168 virtual void reset() { s.reset(); }
169 virtual bool zero() const { return s.zero(); }
170};
171
170struct VectorData : public StatData
172class VectorInfoBase : public Info
171{
173{
174 public:
172 /** Names and descriptions of subfields. */
173 mutable std::vector<std::string> subnames;
174 mutable std::vector<std::string> subdescs;
175
175 /** Names and descriptions of subfields. */
176 mutable std::vector<std::string> subnames;
177 mutable std::vector<std::string> subdescs;
178
179 public:
176 virtual size_type size() const = 0;
177 virtual const VCounter &value() const = 0;
178 virtual const VResult &result() const = 0;
179 virtual Result total() const = 0;
180
181 void
182 update()
183 {

--- 4 unchanged lines hidden (view full) ---

188
189 if (subdescs.size() < s)
190 subdescs.resize(s);
191 }
192 }
193};
194
195template <class Stat>
180 virtual size_type size() const = 0;
181 virtual const VCounter &value() const = 0;
182 virtual const VResult &result() const = 0;
183 virtual Result total() const = 0;
184
185 void
186 update()
187 {

--- 4 unchanged lines hidden (view full) ---

192
193 if (subdescs.size() < s)
194 subdescs.resize(s);
195 }
196 }
197};
198
199template <class Stat>
196class VectorStatData : public VectorData
200class VectorInfo : public VectorInfoBase
197{
198 protected:
199 Stat &s;
200 mutable VCounter cvec;
201 mutable VResult rvec;
202
203 public:
201{
202 protected:
203 Stat &s;
204 mutable VCounter cvec;
205 mutable VResult rvec;
206
207 public:
204 VectorStatData(Stat &stat) : s(stat) {}
208 VectorInfo(Stat &stat) : s(stat) {}
205
206 virtual bool check() const { return s.check(); }
207 virtual bool zero() const { return s.zero(); }
208 virtual void reset() { s.reset(); }
209
210 virtual size_type size() const { return s.size(); }
211
212 virtual VCounter &

--- 16 unchanged lines hidden (view full) ---

229 visit(Visit &visitor)
230 {
231 update();
232 s.update(this);
233 visitor.visit(*this);
234 }
235};
236
209
210 virtual bool check() const { return s.check(); }
211 virtual bool zero() const { return s.zero(); }
212 virtual void reset() { s.reset(); }
213
214 virtual size_type size() const { return s.size(); }
215
216 virtual VCounter &

--- 16 unchanged lines hidden (view full) ---

233 visit(Visit &visitor)
234 {
235 update();
236 s.update(this);
237 visitor.visit(*this);
238 }
239};
240
237struct DistDataData
241struct DistData
238{
239 Counter min_val;
240 Counter max_val;
241 Counter underflow;
242 Counter overflow;
243 VCounter cvec;
244 Counter sum;
245 Counter squares;
246 Counter samples;
247
248 Counter min;
249 Counter max;
250 Counter bucket_size;
251 size_type size;
252 bool fancy;
253};
254
242{
243 Counter min_val;
244 Counter max_val;
245 Counter underflow;
246 Counter overflow;
247 VCounter cvec;
248 Counter sum;
249 Counter squares;
250 Counter samples;
251
252 Counter min;
253 Counter max;
254 Counter bucket_size;
255 size_type size;
256 bool fancy;
257};
258
255struct DistData : public StatData
259class DistInfoBase : public Info
256{
260{
261 public:
257 /** Local storage for the entry values, used for printing. */
262 /** Local storage for the entry values, used for printing. */
258 DistDataData data;
263 DistData data;
259};
260
261template <class Stat>
264};
265
266template <class Stat>
262class DistStatData : public DistData
267class DistInfo : public DistInfoBase
263{
264 protected:
265 Stat &s;
266
267 public:
268{
269 protected:
270 Stat &s;
271
272 public:
268 DistStatData(Stat &stat) : s(stat) {}
273 DistInfo(Stat &stat) : s(stat) {}
269
270 virtual bool check() const { return s.check(); }
271 virtual void reset() { s.reset(); }
272 virtual bool zero() const { return s.zero(); }
273
274 virtual void
275 visit(Visit &visitor)
276 {
277 s.update(this);
278 visitor.visit(*this);
279 }
280};
281
274
275 virtual bool check() const { return s.check(); }
276 virtual void reset() { s.reset(); }
277 virtual bool zero() const { return s.zero(); }
278
279 virtual void
280 visit(Visit &visitor)
281 {
282 s.update(this);
283 visitor.visit(*this);
284 }
285};
286
282struct VectorDistData : public StatData
287class VectorDistInfoBase : public Info
283{
288{
284 std::vector<DistDataData> data;
289 public:
290 std::vector<DistData> data;
285
286 /** Names and descriptions of subfields. */
287 mutable std::vector<std::string> subnames;
288 mutable std::vector<std::string> subdescs;
289
291
292 /** Names and descriptions of subfields. */
293 mutable std::vector<std::string> subnames;
294 mutable std::vector<std::string> subdescs;
295
296 protected:
290 /** Local storage for the entry values, used for printing. */
291 mutable VResult rvec;
292
297 /** Local storage for the entry values, used for printing. */
298 mutable VResult rvec;
299
300 public:
293 virtual size_type size() const = 0;
294
295 void
296 update()
297 {
298 size_type s = size();
299 if (subnames.size() < s)
300 subnames.resize(s);
301
302 if (subdescs.size() < s)
303 subdescs.resize(s);
304 }
305};
306
307template <class Stat>
301 virtual size_type size() const = 0;
302
303 void
304 update()
305 {
306 size_type s = size();
307 if (subnames.size() < s)
308 subnames.resize(s);
309
310 if (subdescs.size() < s)
311 subdescs.resize(s);
312 }
313};
314
315template <class Stat>
308class VectorDistStatData : public VectorDistData
316class VectorDistInfo : public VectorDistInfoBase
309{
310 protected:
311 Stat &s;
312
313 public:
317{
318 protected:
319 Stat &s;
320
321 public:
314 VectorDistStatData(Stat &stat) : s(stat) {}
322 VectorDistInfo(Stat &stat) : s(stat) {}
315
316 virtual bool check() const { return s.check(); }
317 virtual void reset() { s.reset(); }
318 virtual size_type size() const { return s.size(); }
319 virtual bool zero() const { return s.zero(); }
320
321 virtual void
322 visit(Visit &visitor)
323 {
324 update();
325 s.update(this);
326 visitor.visit(*this);
327 }
328};
329
323
324 virtual bool check() const { return s.check(); }
325 virtual void reset() { s.reset(); }
326 virtual size_type size() const { return s.size(); }
327 virtual bool zero() const { return s.zero(); }
328
329 virtual void
330 visit(Visit &visitor)
331 {
332 update();
333 s.update(this);
334 visitor.visit(*this);
335 }
336};
337
330struct Vector2dData : public StatData
338class Vector2dInfoBase : public Info
331{
339{
340 public:
332 /** Names and descriptions of subfields. */
333 std::vector<std::string> subnames;
334 std::vector<std::string> subdescs;
335 std::vector<std::string> y_subnames;
336
337 /** Local storage for the entry values, used for printing. */
338 mutable VCounter cvec;
339 mutable size_type x;
340 mutable size_type y;
341
341 /** Names and descriptions of subfields. */
342 std::vector<std::string> subnames;
343 std::vector<std::string> subdescs;
344 std::vector<std::string> y_subnames;
345
346 /** Local storage for the entry values, used for printing. */
347 mutable VCounter cvec;
348 mutable size_type x;
349 mutable size_type y;
350
351 public:
342 void
343 update()
344 {
345 if (subnames.size() < x)
346 subnames.resize(x);
347 }
348};
349
350template <class Stat>
352 void
353 update()
354 {
355 if (subnames.size() < x)
356 subnames.resize(x);
357 }
358};
359
360template <class Stat>
351class Vector2dStatData : public Vector2dData
361class Vector2dInfo : public Vector2dInfoBase
352{
353 protected:
354 Stat &s;
355
356 public:
362{
363 protected:
364 Stat &s;
365
366 public:
357 Vector2dStatData(Stat &stat) : s(stat) {}
367 Vector2dInfo(Stat &stat) : s(stat) {}
358
359 virtual bool check() const { return s.check(); }
360 virtual void reset() { s.reset(); }
361 virtual bool zero() const { return s.zero(); }
362
363 virtual void
364 visit(Visit &visitor)
365 {
366 update();
367 s.update(this);
368 visitor.visit(*this);
369 }
370};
371
368
369 virtual bool check() const { return s.check(); }
370 virtual void reset() { s.reset(); }
371 virtual bool zero() const { return s.zero(); }
372
373 virtual void
374 visit(Visit &visitor)
375 {
376 update();
377 s.update(this);
378 visitor.visit(*this);
379 }
380};
381
372class DataAccess
382class InfoAccess
373{
374 protected:
383{
384 protected:
375 StatData *find() const;
376 void map(StatData *data);
377
378 StatData *statData();
379 const StatData *statData() const;
380
385 Info *find() const;
386 /** Set up an info class for this statistic */
387 void setInfo(Info *info);
388 /** Save Storage class parameters if any */
381 void setInit();
389 void setInit();
382 void setPrint();
390
391 Info *info();
392 const Info *info() const;
383};
384
393};
394
385template <class Parent, class Child, template <class> class Data>
395template <class Parent, class Child, template <class> class Info>
386class Wrap : public Child
387{
396class Wrap : public Child
397{
398 public:
399 typedef Parent ParentType;
400 typedef Child ChildType;
401 typedef Info<Child> InfoType;
402
388 protected:
389 Parent &self() { return *reinterpret_cast<Parent *>(this); }
390
391 protected:
403 protected:
404 Parent &self() { return *reinterpret_cast<Parent *>(this); }
405
406 protected:
392 Data<Child> *
393 statData()
407 InfoType *
408 info()
394 {
409 {
395 StatData *__data = DataAccess::statData();
396 Data<Child> *ptr = dynamic_cast<Data<Child> *>(__data);
397 assert(ptr);
398 return ptr;
410 return safe_cast<InfoType *>(InfoAccess::info());
399 }
400
401 public:
411 }
412
413 public:
402 const Data<Child> *
403 statData() const
414 const InfoType *
415 info() const
404 {
416 {
405 const StatData *__data = DataAccess::statData();
406 const Data<Child> *ptr = dynamic_cast<const Data<Child> *>(__data);
407 assert(ptr);
408 return ptr;
417 return safe_cast<const InfoType *>(InfoAccess::info());
409 }
410
411 protected:
412 /**
413 * Copy constructor, copies are not allowed.
414 */
415 Wrap(const Wrap &stat);
416
417 /**
418 * Can't copy stats.
419 */
420 void operator=(const Wrap &);
421
422 public:
423 Wrap()
424 {
418 }
419
420 protected:
421 /**
422 * Copy constructor, copies are not allowed.
423 */
424 Wrap(const Wrap &stat);
425
426 /**
427 * Can't copy stats.
428 */
429 void operator=(const Wrap &);
430
431 public:
432 Wrap()
433 {
425 this->map(new Data<Child>(*this));
434 this->setInfo(new InfoType(*this));
426 }
427
428 /**
429 * Set the name and marks this stat to print at the end of simulation.
430 * @param name The new name.
431 * @return A reference to this stat.
432 */
433 Parent &
434 name(const std::string &_name)
435 {
435 }
436
437 /**
438 * Set the name and marks this stat to print at the end of simulation.
439 * @param name The new name.
440 * @return A reference to this stat.
441 */
442 Parent &
443 name(const std::string &_name)
444 {
436 Data<Child> *data = this->statData();
437 data->name = _name;
438 this->setPrint();
445 InfoType *info = this->info();
446 info->name = _name;
447 info->flags |= print;
439 return this->self();
440 }
441
442 /**
443 * Set the description and marks this stat to print at the end of
444 * simulation.
445 * @param desc The new description.
446 * @return A reference to this stat.
447 */
448 Parent &
449 desc(const std::string &_desc)
450 {
448 return this->self();
449 }
450
451 /**
452 * Set the description and marks this stat to print at the end of
453 * simulation.
454 * @param desc The new description.
455 * @return A reference to this stat.
456 */
457 Parent &
458 desc(const std::string &_desc)
459 {
451 this->statData()->desc = _desc;
460 this->info()->desc = _desc;
452 return this->self();
453 }
454
455 /**
456 * Set the precision and marks this stat to print at the end of simulation.
457 * @param p The new precision
458 * @return A reference to this stat.
459 */
460 Parent &
461 precision(int _precision)
462 {
461 return this->self();
462 }
463
464 /**
465 * Set the precision and marks this stat to print at the end of simulation.
466 * @param p The new precision
467 * @return A reference to this stat.
468 */
469 Parent &
470 precision(int _precision)
471 {
463 this->statData()->precision = _precision;
472 this->info()->precision = _precision;
464 return this->self();
465 }
466
467 /**
468 * Set the flags and marks this stat to print at the end of simulation.
469 * @param f The new flags.
470 * @return A reference to this stat.
471 */
472 Parent &
473 flags(StatFlags _flags)
474 {
473 return this->self();
474 }
475
476 /**
477 * Set the flags and marks this stat to print at the end of simulation.
478 * @param f The new flags.
479 * @return A reference to this stat.
480 */
481 Parent &
482 flags(StatFlags _flags)
483 {
475 this->statData()->flags |= _flags;
484 this->info()->flags |= _flags;
476 return this->self();
477 }
478
479 /**
480 * Set the prerequisite stat and marks this stat to print at the end of
481 * simulation.
482 * @param prereq The prerequisite stat.
483 * @return A reference to this stat.
484 */
485 template <class Stat>
486 Parent &
487 prereq(const Stat &prereq)
488 {
485 return this->self();
486 }
487
488 /**
489 * Set the prerequisite stat and marks this stat to print at the end of
490 * simulation.
491 * @param prereq The prerequisite stat.
492 * @return A reference to this stat.
493 */
494 template <class Stat>
495 Parent &
496 prereq(const Stat &prereq)
497 {
489 this->statData()->prereq = prereq.statData();
498 this->info()->prereq = prereq.info();
490 return this->self();
491 }
492};
493
499 return this->self();
500 }
501};
502
494template <class Parent, class Child, template <class Child> class Data>
495class WrapVec : public Wrap<Parent, Child, Data>
503template <class Parent, class Child, template <class Child> class Info>
504class WrapVec : public Wrap<Parent, Child, Info>
496{
497 public:
505{
506 public:
507 typedef Parent ParentType;
508 typedef Child ChildType;
509 typedef Info<Child> InfoType;
510
511 public:
498 // The following functions are specific to vectors. If you use them
499 // in a non vector context, you will get a nice compiler error!
500
501 /**
502 * Set the subfield name for the given index, and marks this stat to print
503 * at the end of simulation.
504 * @param index The subfield index.
505 * @param name The new name of the subfield.
506 * @return A reference to this stat.
507 */
508 Parent &
509 subname(off_type index, const std::string &name)
510 {
512 // The following functions are specific to vectors. If you use them
513 // in a non vector context, you will get a nice compiler error!
514
515 /**
516 * Set the subfield name for the given index, and marks this stat to print
517 * at the end of simulation.
518 * @param index The subfield index.
519 * @param name The new name of the subfield.
520 * @return A reference to this stat.
521 */
522 Parent &
523 subname(off_type index, const std::string &name)
524 {
511 std::vector<std::string> &subn = this->statData()->subnames;
525 std::vector<std::string> &subn = this->info()->subnames;
512 if (subn.size() <= index)
513 subn.resize(index + 1);
514 subn[index] = name;
515 return this->self();
516 }
517
518 /**
519 * Set the subfield description for the given index and marks this stat to
520 * print at the end of simulation.
521 * @param index The subfield index.
522 * @param desc The new description of the subfield
523 * @return A reference to this stat.
524 */
525 Parent &
526 subdesc(off_type index, const std::string &desc)
527 {
526 if (subn.size() <= index)
527 subn.resize(index + 1);
528 subn[index] = name;
529 return this->self();
530 }
531
532 /**
533 * Set the subfield description for the given index and marks this stat to
534 * print at the end of simulation.
535 * @param index The subfield index.
536 * @param desc The new description of the subfield
537 * @return A reference to this stat.
538 */
539 Parent &
540 subdesc(off_type index, const std::string &desc)
541 {
528 std::vector<std::string> &subd = this->statData()->subdescs;
542 std::vector<std::string> &subd = this->info()->subdescs;
529 if (subd.size() <= index)
530 subd.resize(index + 1);
531 subd[index] = desc;
532
533 return this->self();
534 }
535
536};
537
543 if (subd.size() <= index)
544 subd.resize(index + 1);
545 subd[index] = desc;
546
547 return this->self();
548 }
549
550};
551
538template <class Parent, class Child, template <class Child> class Data>
539class WrapVec2d : public WrapVec<Parent, Child, Data>
552template <class Parent, class Child, template <class Child> class Info>
553class WrapVec2d : public WrapVec<Parent, Child, Info>
540{
541 public:
554{
555 public:
556 typedef Parent ParentType;
557 typedef Child ChildType;
558 typedef Info<Child> InfoType;
559
560 public:
542 /**
543 * @warning This makes the assumption that if you're gonna subnames a 2d
544 * vector, you're subnaming across all y
545 */
546 Parent &
547 ysubnames(const char **names)
548 {
561 /**
562 * @warning This makes the assumption that if you're gonna subnames a 2d
563 * vector, you're subnaming across all y
564 */
565 Parent &
566 ysubnames(const char **names)
567 {
549 Data<Child> *data = this->statData();
550 data->y_subnames.resize(this->y);
568 InfoType *info = this->info();
569 info->y_subnames.resize(this->y);
551 for (off_type i = 0; i < this->y; ++i)
570 for (off_type i = 0; i < this->y; ++i)
552 data->y_subnames[i] = names[i];
571 info->y_subnames[i] = names[i];
553 return this->self();
554 }
555
556 Parent &
557 ysubname(off_type index, const std::string subname)
558 {
572 return this->self();
573 }
574
575 Parent &
576 ysubname(off_type index, const std::string subname)
577 {
559 Data<Child> *data = this->statData();
578 InfoType *info = this->info();
560 assert(index < this->y);
579 assert(index < this->y);
561 data->y_subnames.resize(this->y);
562 data->y_subnames[index] = subname.c_str();
580 info->y_subnames.resize(this->y);
581 info->y_subnames[index] = subname.c_str();
563 return this->self();
564 }
565};
566
567//////////////////////////////////////////////////////////////////////
568//
569// Simple Statistics
570//
571//////////////////////////////////////////////////////////////////////
572
573/**
574 * Templatized storage and interface for a simple scalar stat.
575 */
582 return this->self();
583 }
584};
585
586//////////////////////////////////////////////////////////////////////
587//
588// Simple Statistics
589//
590//////////////////////////////////////////////////////////////////////
591
592/**
593 * Templatized storage and interface for a simple scalar stat.
594 */
576struct StatStor
595class StatStor
577{
578 public:
579 /** The paramaters for this storage type, none for a scalar. */
580 struct Params { };
581
582 private:
583 /** The statistic value. */
584 Counter data;

--- 48 unchanged lines hidden (view full) ---

633
634/**
635 * Templatized storage and interface to a per-tick average stat. This keeps
636 * a current count and updates a total (count * ticks) when this count
637 * changes. This allows the quick calculation of a per tick count of the item
638 * being watched. This is good for keeping track of residencies in structures
639 * among other things.
640 */
596{
597 public:
598 /** The paramaters for this storage type, none for a scalar. */
599 struct Params { };
600
601 private:
602 /** The statistic value. */
603 Counter data;

--- 48 unchanged lines hidden (view full) ---

652
653/**
654 * Templatized storage and interface to a per-tick average stat. This keeps
655 * a current count and updates a total (count * ticks) when this count
656 * changes. This allows the quick calculation of a per tick count of the item
657 * being watched. This is good for keeping track of residencies in structures
658 * among other things.
659 */
641struct AvgStor
660class AvgStor
642{
643 public:
644 /** The paramaters for this storage type */
645 struct Params { };
646
647 private:
648 /** The current count. */
649 Counter current;

--- 10 unchanged lines hidden (view full) ---

660
661 /**
662 * Set the current count to the one provided, update the total and last
663 * set values.
664 * @param val The new count.
665 * @param p The parameters for this storage.
666 */
667 void
661{
662 public:
663 /** The paramaters for this storage type */
664 struct Params { };
665
666 private:
667 /** The current count. */
668 Counter current;

--- 10 unchanged lines hidden (view full) ---

679
680 /**
681 * Set the current count to the one provided, update the total and last
682 * set values.
683 * @param val The new count.
684 * @param p The parameters for this storage.
685 */
686 void
668 set(Counter val, Params &p) {
687 set(Counter val, Params &p)
688 {
669 total += current * (curTick - last);
670 last = curTick;
671 current = val;
672 }
673
674 /**
675 * Increment the current count by the provided value, calls set.
676 * @param val The amount to increment.

--- 44 unchanged lines hidden (view full) ---

721 bool zero() const { return total == 0.0; }
722};
723
724/**
725 * Implementation of a scalar stat. The type of stat is determined by the
726 * Storage template.
727 */
728template <class Stor>
689 total += current * (curTick - last);
690 last = curTick;
691 current = val;
692 }
693
694 /**
695 * Increment the current count by the provided value, calls set.
696 * @param val The amount to increment.

--- 44 unchanged lines hidden (view full) ---

741 bool zero() const { return total == 0.0; }
742};
743
744/**
745 * Implementation of a scalar stat. The type of stat is determined by the
746 * Storage template.
747 */
748template <class Stor>
729class ScalarBase : public DataAccess
749class ScalarBase : public InfoAccess
730{
731 public:
732 typedef Stor Storage;
733
734 /** Define the params of the storage class. */
735 typedef typename Storage::Params Params;
736
737 protected:

--- 108 unchanged lines hidden (view full) ---

846 Result result() { return data()->result(params); }
847
848 Result total() { return result(); }
849
850 bool zero() { return result() == 0.0; }
851
852};
853
750{
751 public:
752 typedef Stor Storage;
753
754 /** Define the params of the storage class. */
755 typedef typename Storage::Params Params;
756
757 protected:

--- 108 unchanged lines hidden (view full) ---

866 Result result() { return data()->result(params); }
867
868 Result total() { return result(); }
869
870 bool zero() { return result() == 0.0; }
871
872};
873
854class ProxyData : public ScalarData
874class ProxyInfo : public ScalarInfoBase
855{
856 public:
857 virtual void visit(Visit &visitor) { visitor.visit(*this); }
858 virtual std::string str() const { return to_string(value()); }
859 virtual size_type size() const { return 1; }
860 virtual bool zero() const { return value() == 0; }
861 virtual bool check() const { return true; }
862 virtual void reset() { }
863};
864
865template <class T>
875{
876 public:
877 virtual void visit(Visit &visitor) { visitor.visit(*this); }
878 virtual std::string str() const { return to_string(value()); }
879 virtual size_type size() const { return 1; }
880 virtual bool zero() const { return value() == 0; }
881 virtual bool check() const { return true; }
882 virtual void reset() { }
883};
884
885template <class T>
866class ValueProxy : public ProxyData
886class ValueProxy : public ProxyInfo
867{
868 private:
869 T *scalar;
870
871 public:
872 ValueProxy(T &val) : scalar(&val) {}
873 virtual Counter value() const { return *scalar; }
874 virtual Result result() const { return *scalar; }
875 virtual Result total() const { return *scalar; }
876};
877
878template <class T>
887{
888 private:
889 T *scalar;
890
891 public:
892 ValueProxy(T &val) : scalar(&val) {}
893 virtual Counter value() const { return *scalar; }
894 virtual Result result() const { return *scalar; }
895 virtual Result total() const { return *scalar; }
896};
897
898template <class T>
879class FunctorProxy : public ProxyData
899class FunctorProxy : public ProxyInfo
880{
881 private:
882 T *functor;
883
884 public:
885 FunctorProxy(T &func) : functor(&func) {}
886 virtual Counter value() const { return (*functor)(); }
887 virtual Result result() const { return (*functor)(); }
888 virtual Result total() const { return (*functor)(); }
889};
890
900{
901 private:
902 T *functor;
903
904 public:
905 FunctorProxy(T &func) : functor(&func) {}
906 virtual Counter value() const { return (*functor)(); }
907 virtual Result result() const { return (*functor)(); }
908 virtual Result total() const { return (*functor)(); }
909};
910
891class ValueBase : public DataAccess
911class ValueBase : public InfoAccess
892{
893 private:
912{
913 private:
894 ProxyData *proxy;
914 ProxyInfo *proxy;
895
896 public:
897 ValueBase() : proxy(NULL) { }
898 ~ValueBase() { if (proxy) delete proxy; }
899
900 template <class T>
901 void
902 scalar(T &value)

--- 75 unchanged lines hidden (view full) ---

978 {}
979
980 /**
981 * Set this proxy equal to the provided one.
982 * @param sp The proxy to copy.
983 * @return A reference to this proxy.
984 */
985 const ScalarProxy &
915
916 public:
917 ValueBase() : proxy(NULL) { }
918 ~ValueBase() { if (proxy) delete proxy; }
919
920 template <class T>
921 void
922 scalar(T &value)

--- 75 unchanged lines hidden (view full) ---

998 {}
999
1000 /**
1001 * Set this proxy equal to the provided one.
1002 * @param sp The proxy to copy.
1003 * @return A reference to this proxy.
1004 */
1005 const ScalarProxy &
986 operator=(const ScalarProxy &sp) {
1006 operator=(const ScalarProxy &sp)
1007 {
987 stat = sp.stat;
988 index = sp.index;
989 return *this;
990 }
991
992 public:
993 // Common operators for stats
994 /**

--- 58 unchanged lines hidden (view full) ---

1053 * This stat has no state. Nothing to reset
1054 */
1055 void reset() { }
1056
1057 public:
1058 std::string
1059 str() const
1060 {
1008 stat = sp.stat;
1009 index = sp.index;
1010 return *this;
1011 }
1012
1013 public:
1014 // Common operators for stats
1015 /**

--- 58 unchanged lines hidden (view full) ---

1074 * This stat has no state. Nothing to reset
1075 */
1076 void reset() { }
1077
1078 public:
1079 std::string
1080 str() const
1081 {
1061 return csprintf("%s[%d]", stat->statData()->name, index);
1082 return csprintf("%s[%d]", stat->info()->name, index);
1062 }
1063};
1064
1065/**
1066 * Implementation of a vector of stats. The type of stat is determined by the
1067 * Storage class. @sa ScalarBase
1068 */
1069template <class Stor>
1083 }
1084};
1085
1086/**
1087 * Implementation of a vector of stats. The type of stat is determined by the
1088 * Storage class. @sa ScalarBase
1089 */
1090template <class Stor>
1070class VectorBase : public DataAccess
1091class VectorBase : public InfoAccess
1071{
1072 public:
1073 typedef Stor Storage;
1074
1075 /** Define the params of the storage class. */
1076 typedef typename Storage::Params Params;
1077
1078 /** Proxy type */

--- 123 unchanged lines hidden (view full) ---

1202 */
1203 Proxy
1204 operator[](off_type index)
1205 {
1206 assert (index >= 0 && index < size());
1207 return Proxy(this, index);
1208 }
1209
1092{
1093 public:
1094 typedef Stor Storage;
1095
1096 /** Define the params of the storage class. */
1097 typedef typename Storage::Params Params;
1098
1099 /** Proxy type */

--- 123 unchanged lines hidden (view full) ---

1223 */
1224 Proxy
1225 operator[](off_type index)
1226 {
1227 assert (index >= 0 && index < size());
1228 return Proxy(this, index);
1229 }
1230
1210 void update(StatData *data) {}
1231 void update(Info *data) {}
1211};
1212
1213template <class Stat>
1214class VectorProxy
1215{
1216 private:
1217 Stat *stat;
1218 off_type offset;

--- 68 unchanged lines hidden (view full) ---

1287
1288 /**
1289 * This stat has no state. Nothing to reset.
1290 */
1291 void reset() { }
1292};
1293
1294template <class Stor>
1232};
1233
1234template <class Stat>
1235class VectorProxy
1236{
1237 private:
1238 Stat *stat;
1239 off_type offset;

--- 68 unchanged lines hidden (view full) ---

1308
1309 /**
1310 * This stat has no state. Nothing to reset.
1311 */
1312 void reset() { }
1313};
1314
1315template <class Stor>
1295class Vector2dBase : public DataAccess
1316class Vector2dBase : public InfoAccess
1296{
1297 public:
1298 typedef Stor Storage;
1299 typedef typename Storage::Params Params;
1300 typedef VectorProxy<Vector2dBase<Storage> > Proxy;
1301 friend class ScalarProxy<Vector2dBase<Storage> >;
1302 friend class VectorProxy<Vector2dBase<Storage> >;
1303

--- 9 unchanged lines hidden (view full) ---

1313 const Storage *data(off_type index) const { return &storage[index]; }
1314
1315 void
1316 doInit(size_type _x, size_type _y)
1317 {
1318 assert(_x > 0 && _y > 0 && "sizes must be positive!");
1319 assert(!storage && "already initialized");
1320
1317{
1318 public:
1319 typedef Stor Storage;
1320 typedef typename Storage::Params Params;
1321 typedef VectorProxy<Vector2dBase<Storage> > Proxy;
1322 friend class ScalarProxy<Vector2dBase<Storage> >;
1323 friend class VectorProxy<Vector2dBase<Storage> >;
1324

--- 9 unchanged lines hidden (view full) ---

1334 const Storage *data(off_type index) const { return &storage[index]; }
1335
1336 void
1337 doInit(size_type _x, size_type _y)
1338 {
1339 assert(_x > 0 && _y > 0 && "sizes must be positive!");
1340 assert(!storage && "already initialized");
1341
1321 Vector2dData *statdata = dynamic_cast<Vector2dData *>(find());
1342 Vector2dInfoBase *info = dynamic_cast<Vector2dInfoBase *>(find());
1322
1323 x = _x;
1324 y = _y;
1343
1344 x = _x;
1345 y = _y;
1325 statdata->x = _x;
1326 statdata->y = _y;
1346 info->x = _x;
1347 info->y = _y;
1327 _size = x * y;
1328
1329 char *ptr = new char[_size * sizeof(Storage)];
1330 storage = reinterpret_cast<Storage *>(ptr);
1331
1332 for (off_type i = 0; i < _size; ++i)
1333 new (&storage[i]) Storage(params);
1334

--- 11 unchanged lines hidden (view full) ---

1346 return;
1347
1348 for (off_type i = 0; i < _size; ++i)
1349 data(i)->~Storage();
1350 delete [] reinterpret_cast<char *>(storage);
1351 }
1352
1353 void
1348 _size = x * y;
1349
1350 char *ptr = new char[_size * sizeof(Storage)];
1351 storage = reinterpret_cast<Storage *>(ptr);
1352
1353 for (off_type i = 0; i < _size; ++i)
1354 new (&storage[i]) Storage(params);
1355

--- 11 unchanged lines hidden (view full) ---

1367 return;
1368
1369 for (off_type i = 0; i < _size; ++i)
1370 data(i)->~Storage();
1371 delete [] reinterpret_cast<char *>(storage);
1372 }
1373
1374 void
1354 update(Vector2dData *newdata)
1375 update(Vector2dInfoBase *newinfo)
1355 {
1356 size_type size = this->size();
1376 {
1377 size_type size = this->size();
1357 newdata->cvec.resize(size);
1378 newinfo->cvec.resize(size);
1358 for (off_type i = 0; i < size; ++i)
1379 for (off_type i = 0; i < size; ++i)
1359 newdata->cvec[i] = data(i)->value(params);
1380 newinfo->cvec[i] = data(i)->value();
1360 }
1361
1362 std::string ysubname(off_type i) const { return (*this->y_subnames)[i]; }
1363
1364 Proxy
1365 operator[](off_type index)
1366 {
1367 off_type offset = index * y;

--- 41 unchanged lines hidden (view full) ---

1409//
1410// Non formula statistics
1411//
1412//////////////////////////////////////////////////////////////////////
1413
1414/**
1415 * Templatized storage and interface for a distrbution stat.
1416 */
1381 }
1382
1383 std::string ysubname(off_type i) const { return (*this->y_subnames)[i]; }
1384
1385 Proxy
1386 operator[](off_type index)
1387 {
1388 off_type offset = index * y;

--- 41 unchanged lines hidden (view full) ---

1430//
1431// Non formula statistics
1432//
1433//////////////////////////////////////////////////////////////////////
1434
1435/**
1436 * Templatized storage and interface for a distrbution stat.
1437 */
1417struct DistStor
1438class DistStor
1418{
1419 public:
1420 /** The parameters for a distribution stat. */
1421 struct Params
1422 {
1423 /** The minimum value to track. */
1424 Counter min;
1425 /** The maximum value to track. */

--- 76 unchanged lines hidden (view full) ---

1502 */
1503 bool
1504 zero(const Params &params) const
1505 {
1506 return samples == Counter();
1507 }
1508
1509 void
1439{
1440 public:
1441 /** The parameters for a distribution stat. */
1442 struct Params
1443 {
1444 /** The minimum value to track. */
1445 Counter min;
1446 /** The maximum value to track. */

--- 76 unchanged lines hidden (view full) ---

1523 */
1524 bool
1525 zero(const Params &params) const
1526 {
1527 return samples == Counter();
1528 }
1529
1530 void
1510 update(DistDataData *data, const Params &params)
1531 update(DistData *data, const Params ¶ms)
1511 {
1512 data->min = params.min;
1513 data->max = params.max;
1514 data->bucket_size = params.bucket_size;
1515 data->size = params.size;
1516
1517 data->min_val = (min_val == CounterLimits::max()) ? 0 : min_val;
1518 data->max_val = (max_val == CounterLimits::min()) ? 0 : max_val;

--- 28 unchanged lines hidden (view full) ---

1547 samples = Counter();
1548 }
1549};
1550
1551/**
1552 * Templatized storage and interface for a distribution that calculates mean
1553 * and variance.
1554 */
1532 {
1533 data->min = params.min;
1534 data->max = params.max;
1535 data->bucket_size = params.bucket_size;
1536 data->size = params.size;
1537
1538 data->min_val = (min_val == CounterLimits::max()) ? 0 : min_val;
1539 data->max_val = (max_val == CounterLimits::min()) ? 0 : max_val;

--- 28 unchanged lines hidden (view full) ---

1568 samples = Counter();
1569 }
1570};
1571
1572/**
1573 * Templatized storage and interface for a distribution that calculates mean
1574 * and variance.
1575 */
1555struct FancyStor
1576class FancyStor
1556{
1557 public:
1558 /**
1559 * No paramters for this storage.
1560 */
1561 struct Params {};
1562 enum { fancy = true };
1563

--- 26 unchanged lines hidden (view full) ---

1590 {
1591 Counter value = val * number;
1592 sum += value;
1593 squares += value * value;
1594 samples += number;
1595 }
1596
1597 void
1577{
1578 public:
1579 /**
1580 * No paramters for this storage.
1581 */
1582 struct Params {};
1583 enum { fancy = true };
1584

--- 26 unchanged lines hidden (view full) ---

1611 {
1612 Counter value = val * number;
1613 sum += value;
1614 squares += value * value;
1615 samples += number;
1616 }
1617
1618 void
1598 update(DistDataData *data, const Params &params)
1619 update(DistData *data, const Params ¶ms)
1599 {
1600 data->sum = sum;
1601 data->squares = squares;
1602 data->samples = samples;
1603 }
1604
1605 /**
1606 * Return the number of entries in this stat, 1

--- 18 unchanged lines hidden (view full) ---

1625 samples = Counter();
1626 }
1627};
1628
1629/**
1630 * Templatized storage for distribution that calculates per tick mean and
1631 * variance.
1632 */
1620 {
1621 data->sum = sum;
1622 data->squares = squares;
1623 data->samples = samples;
1624 }
1625
1626 /**
1627 * Return the number of entries in this stat, 1

--- 18 unchanged lines hidden (view full) ---

1646 samples = Counter();
1647 }
1648};
1649
1650/**
1651 * Templatized storage for distribution that calculates per tick mean and
1652 * variance.
1653 */
1633struct AvgFancy
1654class AvgFancy
1634{
1635 public:
1636 /** No parameters for this storage. */
1637 struct Params {};
1638 enum { fancy = true };
1639
1640 private:
1641 /** Current total. */

--- 18 unchanged lines hidden (view full) ---

1660 sample(Counter val, int number, const Params &p)
1661 {
1662 Counter value = val * number;
1663 sum += value;
1664 squares += value * value;
1665 }
1666
1667 void
1655{
1656 public:
1657 /** No parameters for this storage. */
1658 struct Params {};
1659 enum { fancy = true };
1660
1661 private:
1662 /** Current total. */

--- 18 unchanged lines hidden (view full) ---

1681 sample(Counter val, int number, const Params &p)
1682 {
1683 Counter value = val * number;
1684 sum += value;
1685 squares += value * value;
1686 }
1687
1688 void
1668 update(DistDataData *data, const Params &params)
1689 update(DistData *data, const Params ¶ms)
1669 {
1670 data->sum = sum;
1671 data->squares = squares;
1672 data->samples = curTick;
1673 }
1674
1675 /**
1676 * Return the number of entries, in this case 1.

--- 18 unchanged lines hidden (view full) ---

1695 }
1696};
1697
1698/**
1699 * Implementation of a distribution stat. The type of distribution is
1700 * determined by the Storage template. @sa ScalarBase
1701 */
1702template <class Stor>
1690 {
1691 data->sum = sum;
1692 data->squares = squares;
1693 data->samples = curTick;
1694 }
1695
1696 /**
1697 * Return the number of entries, in this case 1.

--- 18 unchanged lines hidden (view full) ---

1716 }
1717};
1718
1719/**
1720 * Implementation of a distribution stat. The type of distribution is
1721 * determined by the Storage template. @sa ScalarBase
1722 */
1723template <class Stor>
1703class DistBase : public DataAccess
1724class DistBase : public InfoAccess
1704{
1705 public:
1706 typedef Stor Storage;
1707 /** Define the params of the storage class. */
1708 typedef typename Storage::Params Params;
1709
1710 protected:
1711 /** The storage for this stat. */

--- 49 unchanged lines hidden (view full) ---

1761 size_type size() const { return data()->size(params); }
1762 /**
1763 * Return true if no samples have been added.
1764 * @return True if there haven't been any samples.
1765 */
1766 bool zero() const { return data()->zero(params); }
1767
1768 void
1725{
1726 public:
1727 typedef Stor Storage;
1728 /** Define the params of the storage class. */
1729 typedef typename Storage::Params Params;
1730
1731 protected:
1732 /** The storage for this stat. */

--- 49 unchanged lines hidden (view full) ---

1782 size_type size() const { return data()->size(params); }
1783 /**
1784 * Return true if no samples have been added.
1785 * @return True if there haven't been any samples.
1786 */
1787 bool zero() const { return data()->zero(params); }
1788
1789 void
1769 update(DistData *base)
1790 update(DistInfoBase *base)
1770 {
1771 base->data.fancy = Storage::fancy;
1772 data()->update(&(base->data), params);
1773 }
1774
1775 /**
1776 * Reset stat value to default
1777 */

--- 9 unchanged lines hidden (view full) ---

1787 return true;
1788 }
1789};
1790
1791template <class Stat>
1792class DistProxy;
1793
1794template <class Stor>
1791 {
1792 base->data.fancy = Storage::fancy;
1793 data()->update(&(base->data), params);
1794 }
1795
1796 /**
1797 * Reset stat value to default
1798 */

--- 9 unchanged lines hidden (view full) ---

1808 return true;
1809 }
1810};
1811
1812template <class Stat>
1813class DistProxy;
1814
1815template <class Stor>
1795class VectorDistBase : public DataAccess
1816class VectorDistBase : public InfoAccess
1796{
1797 public:
1798 typedef Stor Storage;
1799 typedef typename Storage::Params Params;
1800 typedef DistProxy<VectorDistBase<Storage> > Proxy;
1801 friend class DistProxy<VectorDistBase<Storage> >;
1802
1803 protected:

--- 77 unchanged lines hidden (view full) ---

1881
1882 bool
1883 check()
1884 {
1885 return storage != NULL;
1886 }
1887
1888 void
1817{
1818 public:
1819 typedef Stor Storage;
1820 typedef typename Storage::Params Params;
1821 typedef DistProxy<VectorDistBase<Storage> > Proxy;
1822 friend class DistProxy<VectorDistBase<Storage> >;
1823
1824 protected:

--- 77 unchanged lines hidden (view full) ---

1902
1903 bool
1904 check()
1905 {
1906 return storage != NULL;
1907 }
1908
1909 void
1889 update(VectorDistData *base)
1910 update(VectorDistInfoBase *base)
1890 {
1891 size_type size = this->size();
1892 base->data.resize(size);
1893 for (off_type i = 0; i < size; ++i) {
1894 base->data[i].fancy = Storage::fancy;
1895 data(i)->update(&(base->data[i]), params);
1896 }
1897 }

--- 108 unchanged lines hidden (view full) ---

2006};
2007
2008/** Reference counting pointer to a function Node. */
2009typedef RefCountingPtr<Node> NodePtr;
2010
2011class ScalarStatNode : public Node
2012{
2013 private:
1911 {
1912 size_type size = this->size();
1913 base->data.resize(size);
1914 for (off_type i = 0; i < size; ++i) {
1915 base->data[i].fancy = Storage::fancy;
1916 data(i)->update(&(base->data[i]), params);
1917 }
1918 }

--- 108 unchanged lines hidden (view full) ---

2027};
2028
2029/** Reference counting pointer to a function Node. */
2030typedef RefCountingPtr<Node> NodePtr;
2031
2032class ScalarStatNode : public Node
2033{
2034 private:
2014 const ScalarData *data;
2035 const ScalarInfoBase *data;
2015 mutable VResult vresult;
2016
2017 public:
2036 mutable VResult vresult;
2037
2038 public:
2018 ScalarStatNode(const ScalarData *d) : data(d), vresult(1) {}
2039 ScalarStatNode(const ScalarInfoBase *d) : data(d), vresult(1) {}
2019
2020 virtual const VResult &
2021 result() const
2022 {
2023 vresult[0] = data->result();
2024 return vresult;
2025 }
2026

--- 46 unchanged lines hidden (view full) ---

2073 {
2074 return proxy.str();
2075 }
2076};
2077
2078class VectorStatNode : public Node
2079{
2080 private:
2040
2041 virtual const VResult &
2042 result() const
2043 {
2044 vresult[0] = data->result();
2045 return vresult;
2046 }
2047

--- 46 unchanged lines hidden (view full) ---

2094 {
2095 return proxy.str();
2096 }
2097};
2098
2099class VectorStatNode : public Node
2100{
2101 private:
2081 const VectorData *data;
2102 const VectorInfoBase *data;
2082
2083 public:
2103
2104 public:
2084 VectorStatNode(const VectorData *d) : data(d) { }
2105 VectorStatNode(const VectorInfoBase *d) : data(d) { }
2085 virtual const VResult &result() const { return data->result(); }
2086 virtual Result total() const { return data->total(); };
2087
2088 virtual size_type size() const { return data->size(); }
2089
2090 virtual std::string str() const { return data->name; }
2091};
2092

--- 266 unchanged lines hidden (view full) ---

2359 * @{
2360 */
2361
2362/**
2363 * This is a simple scalar statistic, like a counter.
2364 * @sa Stat, ScalarBase, StatStor
2365 */
2366template<int N = 0>
2106 virtual const VResult &result() const { return data->result(); }
2107 virtual Result total() const { return data->total(); };
2108
2109 virtual size_type size() const { return data->size(); }
2110
2111 virtual std::string str() const { return data->name; }
2112};
2113

--- 266 unchanged lines hidden (view full) ---

2380 * @{
2381 */
2382
2383/**
2384 * This is a simple scalar statistic, like a counter.
2385 * @sa Stat, ScalarBase, StatStor
2386 */
2387template<int N = 0>
2367class Scalar : public Wrap<Scalar<N>, ScalarBase<StatStor>, ScalarStatData>
2388class Scalar : public Wrap<Scalar<N>, ScalarBase<StatStor>, ScalarInfo>
2368{
2369 public:
2370 /** The base implementation. */
2371 typedef ScalarBase<StatStor> Base;
2372
2373 Scalar()
2374 {
2375 this->doInit();
2376 }
2377
2378 /**
2379 * Sets the stat equal to the given value. Calls the base implementation
2380 * of operator=
2381 * @param v The new value.
2382 */
2383 template <typename U>
2384 void operator=(const U &v) { Base::operator=(v); }
2385};
2386
2389{
2390 public:
2391 /** The base implementation. */
2392 typedef ScalarBase<StatStor> Base;
2393
2394 Scalar()
2395 {
2396 this->doInit();
2397 }
2398
2399 /**
2400 * Sets the stat equal to the given value. Calls the base implementation
2401 * of operator=
2402 * @param v The new value.
2403 */
2404 template <typename U>
2405 void operator=(const U &v) { Base::operator=(v); }
2406};
2407
2387class Value : public Wrap<Value, ValueBase, ScalarStatData>
2408class Value : public Wrap<Value, ValueBase, ScalarInfo>
2388{
2389 public:
2390 /** The base implementation. */
2391 typedef ValueBase Base;
2392
2393 template <class T>
2394 Value &
2395 scalar(T &value)

--- 11 unchanged lines hidden (view full) ---

2407 }
2408};
2409
2410/**
2411 * A stat that calculates the per tick average of a value.
2412 * @sa Stat, ScalarBase, AvgStor
2413 */
2414template<int N = 0>
2409{
2410 public:
2411 /** The base implementation. */
2412 typedef ValueBase Base;
2413
2414 template <class T>
2415 Value &
2416 scalar(T &value)

--- 11 unchanged lines hidden (view full) ---

2428 }
2429};
2430
2431/**
2432 * A stat that calculates the per tick average of a value.
2433 * @sa Stat, ScalarBase, AvgStor
2434 */
2435template<int N = 0>
2415class Average : public Wrap<Average<N>, ScalarBase<AvgStor>, ScalarStatData>
2436class Average : public Wrap<Average<N>, ScalarBase<AvgStor>, ScalarInfo>
2416{
2417 public:
2418 /** The base implementation. */
2419 typedef ScalarBase<AvgStor> Base;
2420
2421 Average()
2422 {
2423 this->doInit();

--- 12 unchanged lines hidden (view full) ---

2436 }
2437};
2438
2439/**
2440 * A vector of scalar stats.
2441 * @sa Stat, VectorBase, StatStor
2442 */
2443template<int N = 0>
2437{
2438 public:
2439 /** The base implementation. */
2440 typedef ScalarBase<AvgStor> Base;
2441
2442 Average()
2443 {
2444 this->doInit();

--- 12 unchanged lines hidden (view full) ---

2457 }
2458};
2459
2460/**
2461 * A vector of scalar stats.
2462 * @sa Stat, VectorBase, StatStor
2463 */
2464template<int N = 0>
2444class Vector : public WrapVec<Vector<N>, VectorBase<StatStor>, VectorStatData>
2465class Vector : public WrapVec<Vector<N>, VectorBase<StatStor>, VectorInfo>
2445{
2446 public:
2447 /** The base implementation. */
2448 typedef ScalarBase<StatStor> Base;
2449
2450 /**
2451 * Set this vector to have the given size.
2452 * @param size The new size.

--- 8 unchanged lines hidden (view full) ---

2461};
2462
2463/**
2464 * A vector of Average stats.
2465 * @sa Stat, VectorBase, AvgStor
2466 */
2467template<int N = 0>
2468class AverageVector
2466{
2467 public:
2468 /** The base implementation. */
2469 typedef ScalarBase<StatStor> Base;
2470
2471 /**
2472 * Set this vector to have the given size.
2473 * @param size The new size.

--- 8 unchanged lines hidden (view full) ---

2482};
2483
2484/**
2485 * A vector of Average stats.
2486 * @sa Stat, VectorBase, AvgStor
2487 */
2488template<int N = 0>
2489class AverageVector
2469 : public WrapVec<AverageVector<N>, VectorBase<AvgStor>, VectorStatData>
2490 : public WrapVec<AverageVector<N>, VectorBase<AvgStor>, VectorInfo>
2470{
2471 public:
2472 /**
2473 * Set this vector to have the given size.
2474 * @param size The new size.
2475 * @return A reference to this stat.
2476 */
2477 AverageVector &

--- 5 unchanged lines hidden (view full) ---

2483};
2484
2485/**
2486 * A 2-Dimensional vecto of scalar stats.
2487 * @sa Stat, Vector2dBase, StatStor
2488 */
2489template<int N = 0>
2490class Vector2d
2491{
2492 public:
2493 /**
2494 * Set this vector to have the given size.
2495 * @param size The new size.
2496 * @return A reference to this stat.
2497 */
2498 AverageVector &

--- 5 unchanged lines hidden (view full) ---

2504};
2505
2506/**
2507 * A 2-Dimensional vecto of scalar stats.
2508 * @sa Stat, Vector2dBase, StatStor
2509 */
2510template<int N = 0>
2511class Vector2d
2491 : public WrapVec2d<Vector2d<N>, Vector2dBase<StatStor>, Vector2dStatData>
2512 : public WrapVec2d<Vector2d<N>, Vector2dBase<StatStor>, Vector2dInfo>
2492{
2493 public:
2494 Vector2d &
2495 init(size_type x, size_type y)
2496 {
2497 this->doInit(x, y);
2498 return *this;
2499 }
2500};
2501
2502/**
2503 * A simple distribution stat.
2504 * @sa Stat, DistBase, DistStor
2505 */
2506template<int N = 0>
2507class Distribution
2513{
2514 public:
2515 Vector2d &
2516 init(size_type x, size_type y)
2517 {
2518 this->doInit(x, y);
2519 return *this;
2520 }
2521};
2522
2523/**
2524 * A simple distribution stat.
2525 * @sa Stat, DistBase, DistStor
2526 */
2527template<int N = 0>
2528class Distribution
2508 : public Wrap<Distribution<N>, DistBase<DistStor>, DistStatData>
2529 : public Wrap<Distribution<N>, DistBase<DistStor>, DistInfo>
2509{
2510 public:
2511 /** Base implementation. */
2512 typedef DistBase<DistStor> Base;
2513 /** The Parameter type. */
2514 typedef DistStor::Params Params;
2515
2516 public:

--- 17 unchanged lines hidden (view full) ---

2534};
2535
2536/**
2537 * Calculates the mean and variance of all the samples.
2538 * @sa Stat, DistBase, FancyStor
2539 */
2540template<int N = 0>
2541class StandardDeviation
2530{
2531 public:
2532 /** Base implementation. */
2533 typedef DistBase<DistStor> Base;
2534 /** The Parameter type. */
2535 typedef DistStor::Params Params;
2536
2537 public:

--- 17 unchanged lines hidden (view full) ---

2555};
2556
2557/**
2558 * Calculates the mean and variance of all the samples.
2559 * @sa Stat, DistBase, FancyStor
2560 */
2561template<int N = 0>
2562class StandardDeviation
2542 : public Wrap<StandardDeviation<N>, DistBase<FancyStor>, DistStatData>
2563 : public Wrap<StandardDeviation<N>, DistBase<FancyStor>, DistInfo>
2543{
2544 public:
2545 /** The base implementation */
2546 typedef DistBase<DistStor> Base;
2547 /** The parameter type. */
2548 typedef DistStor::Params Params;
2549
2550 public:

--- 7 unchanged lines hidden (view full) ---

2558};
2559
2560/**
2561 * Calculates the per tick mean and variance of the samples.
2562 * @sa Stat, DistBase, AvgFancy
2563 */
2564template<int N = 0>
2565class AverageDeviation
2564{
2565 public:
2566 /** The base implementation */
2567 typedef DistBase<DistStor> Base;
2568 /** The parameter type. */
2569 typedef DistStor::Params Params;
2570
2571 public:

--- 7 unchanged lines hidden (view full) ---

2579};
2580
2581/**
2582 * Calculates the per tick mean and variance of the samples.
2583 * @sa Stat, DistBase, AvgFancy
2584 */
2585template<int N = 0>
2586class AverageDeviation
2566 : public Wrap<AverageDeviation<N>, DistBase<AvgFancy>, DistStatData>
2587 : public Wrap<AverageDeviation<N>, DistBase<AvgFancy>, DistInfo>
2567{
2568 public:
2569 /** The base implementation */
2570 typedef DistBase<DistStor> Base;
2571 /** The parameter type. */
2572 typedef DistStor::Params Params;
2573
2574 public:

--- 9 unchanged lines hidden (view full) ---

2584/**
2585 * A vector of distributions.
2586 * @sa Stat, VectorDistBase, DistStor
2587 */
2588template<int N = 0>
2589class VectorDistribution
2590 : public WrapVec<VectorDistribution<N>,
2591 VectorDistBase<DistStor>,
2588{
2589 public:
2590 /** The base implementation */
2591 typedef DistBase<DistStor> Base;
2592 /** The parameter type. */
2593 typedef DistStor::Params Params;
2594
2595 public:

--- 9 unchanged lines hidden (view full) ---

2605/**
2606 * A vector of distributions.
2607 * @sa Stat, VectorDistBase, DistStor
2608 */
2609template<int N = 0>
2610class VectorDistribution
2611 : public WrapVec<VectorDistribution<N>,
2612 VectorDistBase<DistStor>,
2592 VectorDistStatData>
2613 VectorDistInfo>
2593{
2594 public:
2595 /** The base implementation */
2596 typedef VectorDistBase<DistStor> Base;
2597 /** The parameter type. */
2598 typedef DistStor::Params Params;
2599
2600 public:

--- 20 unchanged lines hidden (view full) ---

2621/**
2622 * This is a vector of StandardDeviation stats.
2623 * @sa Stat, VectorDistBase, FancyStor
2624 */
2625template<int N = 0>
2626class VectorStandardDeviation
2627 : public WrapVec<VectorStandardDeviation<N>,
2628 VectorDistBase<FancyStor>,
2614{
2615 public:
2616 /** The base implementation */
2617 typedef VectorDistBase<DistStor> Base;
2618 /** The parameter type. */
2619 typedef DistStor::Params Params;
2620
2621 public:

--- 20 unchanged lines hidden (view full) ---

2642/**
2643 * This is a vector of StandardDeviation stats.
2644 * @sa Stat, VectorDistBase, FancyStor
2645 */
2646template<int N = 0>
2647class VectorStandardDeviation
2648 : public WrapVec<VectorStandardDeviation<N>,
2649 VectorDistBase<FancyStor>,
2629 VectorDistStatData>
2650 VectorDistInfo>
2630{
2631 public:
2632 /** The base implementation */
2633 typedef VectorDistBase<FancyStor> Base;
2634 /** The parameter type. */
2635 typedef DistStor::Params Params;
2636
2637 public:

--- 13 unchanged lines hidden (view full) ---

2651/**
2652 * This is a vector of AverageDeviation stats.
2653 * @sa Stat, VectorDistBase, AvgFancy
2654 */
2655template<int N = 0>
2656class VectorAverageDeviation
2657 : public WrapVec<VectorAverageDeviation<N>,
2658 VectorDistBase<AvgFancy>,
2651{
2652 public:
2653 /** The base implementation */
2654 typedef VectorDistBase<FancyStor> Base;
2655 /** The parameter type. */
2656 typedef DistStor::Params Params;
2657
2658 public:

--- 13 unchanged lines hidden (view full) ---

2672/**
2673 * This is a vector of AverageDeviation stats.
2674 * @sa Stat, VectorDistBase, AvgFancy
2675 */
2676template<int N = 0>
2677class VectorAverageDeviation
2678 : public WrapVec<VectorAverageDeviation<N>,
2679 VectorDistBase<AvgFancy>,
2659 VectorDistStatData>
2680 VectorDistInfo>
2660{
2661 public:
2662 /** The base implementation */
2663 typedef VectorDistBase<AvgFancy> Base;
2664 /** The parameter type. */
2665 typedef DistStor::Params Params;
2666
2667 public:

--- 10 unchanged lines hidden (view full) ---

2678 }
2679};
2680
2681/**
2682 * A formula for statistics that is calculated when printed. A formula is
2683 * stored as a tree of Nodes that represent the equation to calculate.
2684 * @sa Stat, ScalarStat, VectorStat, Node, Temp
2685 */
2681{
2682 public:
2683 /** The base implementation */
2684 typedef VectorDistBase<AvgFancy> Base;
2685 /** The parameter type. */
2686 typedef DistStor::Params Params;
2687
2688 public:

--- 10 unchanged lines hidden (view full) ---

2699 }
2700};
2701
2702/**
2703 * A formula for statistics that is calculated when printed. A formula is
2704 * stored as a tree of Nodes that represent the equation to calculate.
2705 * @sa Stat, ScalarStat, VectorStat, Node, Temp
2706 */
2686class FormulaBase : public DataAccess
2707class FormulaBase : public InfoAccess
2687{
2688 protected:
2689 /** The root of the tree which represents the Formula */
2690 NodePtr root;
2691 friend class Temp;
2692
2693 public:
2694 /**

--- 32 unchanged lines hidden (view full) ---

2727 /**
2728 *
2729 */
2730 bool zero() const;
2731
2732 /**
2733 *
2734 */
2708{
2709 protected:
2710 /** The root of the tree which represents the Formula */
2711 NodePtr root;
2712 friend class Temp;
2713
2714 public:
2715 /**

--- 32 unchanged lines hidden (view full) ---

2748 /**
2749 *
2750 */
2751 bool zero() const;
2752
2753 /**
2754 *
2755 */
2735 void update(StatData *);
2756 void update(Info *);
2736
2737 std::string str() const;
2738};
2739
2757
2758 std::string str() const;
2759};
2760
2740class FormulaData : public VectorData
2761class FormulaInfoBase : public VectorInfoBase
2741{
2742 public:
2743 virtual std::string str() const = 0;
2744 virtual bool check() const { return true; }
2745};
2746
2747template <class Stat>
2762{
2763 public:
2764 virtual std::string str() const = 0;
2765 virtual bool check() const { return true; }
2766};
2767
2768template <class Stat>
2748class FormulaStatData : public FormulaData
2769class FormulaInfo : public FormulaInfoBase
2749{
2750 protected:
2751 Stat &s;
2752 mutable VResult vec;
2753 mutable VCounter cvec;
2754
2755 public:
2770{
2771 protected:
2772 Stat &s;
2773 mutable VResult vec;
2774 mutable VCounter cvec;
2775
2776 public:
2756 FormulaStatData(Stat &stat) : s(stat) {}
2777 FormulaInfo(Stat &stat) : s(stat) {}
2757
2758 virtual bool zero() const { return s.zero(); }
2759 virtual void reset() { s.reset(); }
2760
2761 virtual size_type size() const { return s.size(); }
2762
2763 virtual const VResult &
2764 result() const

--- 14 unchanged lines hidden (view full) ---

2779
2780 virtual std::string str() const { return s.str(); }
2781};
2782
2783class Temp;
2784class Formula
2785 : public WrapVec<Formula,
2786 FormulaBase,
2778
2779 virtual bool zero() const { return s.zero(); }
2780 virtual void reset() { s.reset(); }
2781
2782 virtual size_type size() const { return s.size(); }
2783
2784 virtual const VResult &
2785 result() const

--- 14 unchanged lines hidden (view full) ---

2800
2801 virtual std::string str() const { return s.str(); }
2802};
2803
2804class Temp;
2805class Formula
2806 : public WrapVec<Formula,
2807 FormulaBase,
2787 FormulaStatData>
2808 FormulaInfo>
2788{
2789 public:
2790 /**
2791 * Create and initialize thie formula, and register it with the database.
2792 */
2793 Formula();
2794
2795 /**

--- 60 unchanged lines hidden (view full) ---

2856
2857 public:
2858 /**
2859 * Create a new ScalarStatNode.
2860 * @param s The ScalarStat to place in a node.
2861 */
2862 template <int N>
2863 Temp(const Scalar<N> &s)
2809{
2810 public:
2811 /**
2812 * Create and initialize thie formula, and register it with the database.
2813 */
2814 Formula();
2815
2816 /**

--- 60 unchanged lines hidden (view full) ---

2877
2878 public:
2879 /**
2880 * Create a new ScalarStatNode.
2881 * @param s The ScalarStat to place in a node.
2882 */
2883 template <int N>
2884 Temp(const Scalar<N> &s)
2864 : node(new ScalarStatNode(s.statData()))
2885 : node(new ScalarStatNode(s.info()))
2865 { }
2866
2867 /**
2868 * Create a new ScalarStatNode.
2869 * @param s The ScalarStat to place in a node.
2870 */
2871 Temp(const Value &s)
2886 { }
2887
2888 /**
2889 * Create a new ScalarStatNode.
2890 * @param s The ScalarStat to place in a node.
2891 */
2892 Temp(const Value &s)
2872 : node(new ScalarStatNode(s.statData()))
2893 : node(new ScalarStatNode(s.info()))
2873 { }
2874
2875 /**
2876 * Create a new ScalarStatNode.
2877 * @param s The ScalarStat to place in a node.
2878 */
2879 template <int N>
2880 Temp(const Average<N> &s)
2894 { }
2895
2896 /**
2897 * Create a new ScalarStatNode.
2898 * @param s The ScalarStat to place in a node.
2899 */
2900 template <int N>
2901 Temp(const Average<N> &s)
2881 : node(new ScalarStatNode(s.statData()))
2902 : node(new ScalarStatNode(s.info()))
2882 { }
2883
2884 /**
2885 * Create a new VectorStatNode.
2886 * @param s The VectorStat to place in a node.
2887 */
2888 template <int N>
2889 Temp(const Vector<N> &s)
2903 { }
2904
2905 /**
2906 * Create a new VectorStatNode.
2907 * @param s The VectorStat to place in a node.
2908 */
2909 template <int N>
2910 Temp(const Vector<N> &s)
2890 : node(new VectorStatNode(s.statData()))
2911 : node(new VectorStatNode(s.info()))
2891 { }
2892
2893 /**
2894 *
2895 */
2896 Temp(const Formula &f)
2897 : node(new FormulaNode(f))
2898 { }

--- 170 unchanged lines hidden ---
2912 { }
2913
2914 /**
2915 *
2916 */
2917 Temp(const Formula &f)
2918 : node(new FormulaNode(f))
2919 { }

--- 170 unchanged lines hidden ---