statistics.hh (6128:fdfbd4c6e449) | statistics.hh (6129:05405c5b8c16) |
---|---|
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; --- 51 unchanged lines hidden (view full) --- 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" | 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; --- 51 unchanged lines hidden (view full) --- 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" | 68#include "base/stats/info.hh" |
69#include "base/stats/types.hh" | 69#include "base/stats/types.hh" |
70#include "base/stats/visit.hh" |
|
70#include "sim/host.hh" 71 72class Callback; 73 74/** The current simulated tick. */ 75extern Tick curTick; 76 77/* A namespace for all of the Statistics */ 78namespace Stats { 79 | 71#include "sim/host.hh" 72 73class Callback; 74 75/** The current simulated tick. */ 76extern Tick curTick; 77 78/* A namespace for all of the Statistics */ 79namespace Stats { 80 |
80struct StorageParams 81{ 82 virtual ~StorageParams(); 83}; 84 85////////////////////////////////////////////////////////////////////// 86// 87// Statistics Framework Base classes 88// 89////////////////////////////////////////////////////////////////////// 90class Info 91{ 92 public: 93 /** The name of the stat. */ 94 std::string name; 95 /** The description of the stat. */ 96 std::string desc; 97 /** The formatting flags. */ 98 StatFlags flags; 99 /** The display precision. */ 100 int precision; 101 /** A pointer to a prerequisite Stat. */ 102 const Info *prereq; 103 /** 104 * A unique stat ID for each stat in the simulator. 105 * Can be used externally for lookups as well as for debugging. 106 */ 107 static int id_count; 108 int id; 109 110 public: 111 const StorageParams *storageParams; 112 113 public: 114 Info(); 115 virtual ~Info(); 116 117 /** Set the name of this statistic */ 118 void setName(const std::string &name); 119 120 /** 121 * Check that this stat has been set up properly and is ready for 122 * use 123 * @return true for success 124 */ 125 virtual bool check() const = 0; 126 bool baseCheck() const; 127 128 /** 129 * Enable the stat for use 130 */ 131 virtual void enable(); 132 133 /** 134 * Prepare the stat for dumping. 135 */ 136 virtual void prepare() = 0; 137 138 /** 139 * Reset the stat to the default state. 140 */ 141 virtual void reset() = 0; 142 143 /** 144 * @return true if this stat has a value and satisfies its 145 * requirement as a prereq 146 */ 147 virtual bool zero() const = 0; 148 149 /** 150 * Visitor entry for outputing statistics data 151 */ 152 virtual void visit(Visit &visitor) = 0; 153 154 /** 155 * Checks if the first stat's name is alphabetically less than the second. 156 * This function breaks names up at periods and considers each subname 157 * separately. 158 * @param stat1 The first stat. 159 * @param stat2 The second stat. 160 * @return stat1's name is alphabetically before stat2's 161 */ 162 static bool less(Info *stat1, Info *stat2); 163}; 164struct StorageParams; 165 | |
166template <class Stat, class Base> 167class InfoProxy : public Base 168{ 169 protected: 170 Stat &s; 171 172 public: 173 InfoProxy(Stat &stat) : s(stat) {} --- 4 unchanged lines hidden (view full) --- 178 void 179 visit(Visit &visitor) 180 { 181 visitor.visit(*static_cast<Base *>(this)); 182 } 183 bool zero() const { return s.zero(); } 184}; 185 | 81template <class Stat, class Base> 82class InfoProxy : public Base 83{ 84 protected: 85 Stat &s; 86 87 public: 88 InfoProxy(Stat &stat) : s(stat) {} --- 4 unchanged lines hidden (view full) --- 93 void 94 visit(Visit &visitor) 95 { 96 visitor.visit(*static_cast<Base *>(this)); 97 } 98 bool zero() const { return s.zero(); } 99}; 100 |
186class ScalarInfo : public Info 187{ 188 public: 189 virtual Counter value() const = 0; 190 virtual Result result() const = 0; 191 virtual Result total() const = 0; 192}; 193 | |
194template <class Stat> 195class ScalarInfoProxy : public InfoProxy<Stat, ScalarInfo> 196{ 197 public: 198 ScalarInfoProxy(Stat &stat) : InfoProxy<Stat, ScalarInfo>(stat) {} 199 200 Counter value() const { return this->s.value(); } 201 Result result() const { return this->s.result(); } 202 Result total() const { return this->s.total(); } 203}; 204 | 101template <class Stat> 102class ScalarInfoProxy : public InfoProxy<Stat, ScalarInfo> 103{ 104 public: 105 ScalarInfoProxy(Stat &stat) : InfoProxy<Stat, ScalarInfo>(stat) {} 106 107 Counter value() const { return this->s.value(); } 108 Result result() const { return this->s.result(); } 109 Result total() const { return this->s.total(); } 110}; 111 |
205class VectorInfo : public Info 206{ 207 public: 208 /** Names and descriptions of subfields. */ 209 std::vector<std::string> subnames; 210 std::vector<std::string> subdescs; 211 212 public: 213 void enable(); 214 215 public: 216 virtual size_type size() const = 0; 217 virtual const VCounter &value() const = 0; 218 virtual const VResult &result() const = 0; 219 virtual Result total() const = 0; 220}; 221 | |
222template <class Stat> 223class VectorInfoProxy : public InfoProxy<Stat, VectorInfo> 224{ 225 protected: 226 mutable VCounter cvec; 227 mutable VResult rvec; 228 229 public: --- 13 unchanged lines hidden (view full) --- 243 { 244 this->s.result(rvec); 245 return rvec; 246 } 247 248 Result total() const { return this->s.total(); } 249}; 250 | 112template <class Stat> 113class VectorInfoProxy : public InfoProxy<Stat, VectorInfo> 114{ 115 protected: 116 mutable VCounter cvec; 117 mutable VResult rvec; 118 119 public: --- 13 unchanged lines hidden (view full) --- 133 { 134 this->s.result(rvec); 135 return rvec; 136 } 137 138 Result total() const { return this->s.total(); } 139}; 140 |
251struct DistData 252{ 253 Counter min_val; 254 Counter max_val; 255 Counter underflow; 256 Counter overflow; 257 VCounter cvec; 258 Counter sum; 259 Counter squares; 260 Counter samples; 261}; 262 263class DistInfo : public Info 264{ 265 public: 266 /** Local storage for the entry values, used for printing. */ 267 DistData data; 268}; 269 | |
270template <class Stat> 271class DistInfoProxy : public InfoProxy<Stat, DistInfo> 272{ 273 public: 274 DistInfoProxy(Stat &stat) : InfoProxy<Stat, DistInfo>(stat) {} 275}; 276 | 141template <class Stat> 142class DistInfoProxy : public InfoProxy<Stat, DistInfo> 143{ 144 public: 145 DistInfoProxy(Stat &stat) : InfoProxy<Stat, DistInfo>(stat) {} 146}; 147 |
277class VectorDistInfo : public Info 278{ 279 public: 280 std::vector<DistData> data; 281 282 /** Names and descriptions of subfields. */ 283 std::vector<std::string> subnames; 284 std::vector<std::string> subdescs; 285 void enable(); 286 287 protected: 288 /** Local storage for the entry values, used for printing. */ 289 mutable VResult rvec; 290 291 public: 292 virtual size_type size() const = 0; 293}; 294 | |
295template <class Stat> 296class VectorDistInfoProxy : public InfoProxy<Stat, VectorDistInfo> 297{ 298 public: 299 VectorDistInfoProxy(Stat &stat) : InfoProxy<Stat, VectorDistInfo>(stat) {} 300 301 size_type size() const { return this->s.size(); } 302}; 303 | 148template <class Stat> 149class VectorDistInfoProxy : public InfoProxy<Stat, VectorDistInfo> 150{ 151 public: 152 VectorDistInfoProxy(Stat &stat) : InfoProxy<Stat, VectorDistInfo>(stat) {} 153 154 size_type size() const { return this->s.size(); } 155}; 156 |
304class Vector2dInfo : public Info 305{ 306 public: 307 /** Names and descriptions of subfields. */ 308 std::vector<std::string> subnames; 309 std::vector<std::string> subdescs; 310 std::vector<std::string> y_subnames; 311 312 size_type x; 313 size_type y; 314 315 /** Local storage for the entry values, used for printing. */ 316 mutable VCounter cvec; 317 318 void enable(); 319}; 320 | |
321template <class Stat> 322class Vector2dInfoProxy : public InfoProxy<Stat, Vector2dInfo> 323{ 324 public: 325 Vector2dInfoProxy(Stat &stat) : InfoProxy<Stat, Vector2dInfo>(stat) {} 326}; 327 328class InfoAccess --- 1093 unchanged lines hidden (view full) --- 1422}; 1423 1424////////////////////////////////////////////////////////////////////// 1425// 1426// Non formula statistics 1427// 1428////////////////////////////////////////////////////////////////////// 1429 | 157template <class Stat> 158class Vector2dInfoProxy : public InfoProxy<Stat, Vector2dInfo> 159{ 160 public: 161 Vector2dInfoProxy(Stat &stat) : InfoProxy<Stat, Vector2dInfo>(stat) {} 162}; 163 164class InfoAccess --- 1093 unchanged lines hidden (view full) --- 1258}; 1259 1260////////////////////////////////////////////////////////////////////// 1261// 1262// Non formula statistics 1263// 1264////////////////////////////////////////////////////////////////////// 1265 |
1430struct DistParams : public StorageParams 1431{ 1432 const bool fancy; 1433 1434 /** The minimum value to track. */ 1435 Counter min; 1436 /** The maximum value to track. */ 1437 Counter max; 1438 /** The number of entries in each bucket. */ 1439 Counter bucket_size; 1440 /** The number of buckets. Equal to (max-min)/bucket_size. */ 1441 size_type buckets; 1442 1443 explicit DistParams(bool f) : fancy(f) {} 1444}; 1445 | |
1446/** 1447 * Templatized storage and interface for a distrbution stat. 1448 */ 1449class DistStor 1450{ 1451 public: 1452 /** The parameters for a distribution stat. */ 1453 struct Params : public DistParams --- 1096 unchanged lines hidden (view full) --- 2550 VectorAverageDeviation & 2551 init(size_type size) 2552 { 2553 this->doInit(size); 2554 return this->self(); 2555 } 2556}; 2557 | 1266/** 1267 * Templatized storage and interface for a distrbution stat. 1268 */ 1269class DistStor 1270{ 1271 public: 1272 /** The parameters for a distribution stat. */ 1273 struct Params : public DistParams --- 1096 unchanged lines hidden (view full) --- 2370 VectorAverageDeviation & 2371 init(size_type size) 2372 { 2373 this->doInit(size); 2374 return this->self(); 2375 } 2376}; 2377 |
2558class FormulaInfo : public VectorInfo 2559{ 2560 public: 2561 virtual std::string str() const = 0; 2562}; 2563 | |
2564template <class Stat> 2565class FormulaInfoProxy : public InfoProxy<Stat, FormulaInfo> 2566{ 2567 protected: 2568 mutable VResult vec; 2569 mutable VCounter cvec; 2570 2571 public: --- 370 unchanged lines hidden --- | 2378template <class Stat> 2379class FormulaInfoProxy : public InfoProxy<Stat, FormulaInfo> 2380{ 2381 protected: 2382 mutable VResult vec; 2383 mutable VCounter cvec; 2384 2385 public: --- 370 unchanged lines hidden --- |