1 2 /* Web Polygraph http://www.web-polygraph.org/ 3 * Copyright 2003-2011 The Measurement Factory 4 * Licensed under the Apache License, Version 2.0 */ 5 6 #ifndef POLYGRAPH__LOGANALYZERS_STEX_H 7 #define POLYGRAPH__LOGANALYZERS_STEX_H 8 9 #include "xstd/String.h" 10 #include "base/StatPhaseRec.h" 11 12 class XmlNodes; 13 class PhaseInfo; 14 15 16 // an algorithm of extracting a particular named statistics out of 17 // cycle or phase stats record and describing/categorizing that statistics 18 class Stex { 19 public: 20 typedef AggrStat StatPhaseRec::*AggrPtr; 21 typedef TmSzHistStat StatPhaseRec::*HistPtr; 22 typedef ContType::AggrStat StatIntvlRec::*ContTypeAggrPtr; 23 typedef ContType::HistStat StatPhaseRec::*ContTypeHistPtr; 24 typedef HRHistStat StatPhaseRec::*HRHistPtr; 25 typedef CompoundXactStat StatPhaseRec::*CompoundPtr; 26 typedef TmSzStat StatIntvlRec::*TracePtr; 27 typedef StatusCodeStat StatPhaseRec::*StatusCodePtr; 28 29 public: 30 Stex(const String &aKey, const String &aName); 31 virtual ~Stex(); 32 33 void parent(const Stex *aParent); 34 key()35 const String &key() const { return theKey; } // precise, for machine use name()36 const String &name() const { return theName; } // imprecise, human-readable parent()37 const Stex *parent() const { return theParent; } ignoreUnseen()38 bool ignoreUnseen() const { return doIgnoreUnseen; } 39 double totalCount(const PhaseInfo &phase) const; 40 double meanPartsCount(const PhaseInfo &phase) const; 41 int cmpByCountContrib(const PhaseInfo &phase, const Stex &stex) const; 42 43 virtual const TmSzStat *aggr(const PhaseInfo &phase) const; hist(const PhaseInfo &)44 virtual const TmSzHistStat *hist(const PhaseInfo &) const { return 0; } trace(const StatIntvlRec &)45 virtual const TmSzStat *trace(const StatIntvlRec &) const { return 0; } partsHist(const PhaseInfo &)46 virtual const Histogram *partsHist(const PhaseInfo &) const { return 0; } 47 virtual const AggrStat *partsStat(const PhaseInfo &phase) const; 48 49 virtual void describe(XmlNodes &nodes) const = 0; 50 51 protected: 52 void describeParent(XmlNodes &nodes) const; 53 54 protected: 55 const String theKey; 56 const String theName; 57 const Stex *theParent; // if we are a part of a 'larger' stats group 58 bool doIgnoreUnseen; // if stex should be added to the unseen stat list 59 }; 60 61 62 class HitsStex: public Stex { 63 public: 64 HitsStex(const String &aKey, const String &aName); 65 66 virtual const TmSzHistStat *hist(const PhaseInfo &phase) const; 67 virtual const TmSzStat *trace(const StatIntvlRec &rec) const; 68 69 virtual void describe(XmlNodes &nodes) const; 70 }; 71 72 class MissesStex: public Stex { 73 public: 74 MissesStex(const String &aKey, const String &aName); 75 76 virtual const TmSzHistStat *hist(const PhaseInfo &phase) const; 77 virtual const TmSzStat *trace(const StatIntvlRec &rec) const; 78 79 virtual void describe(XmlNodes &nodes) const; 80 }; 81 82 class HitMissesStex: public Stex { 83 public: 84 HitMissesStex(const String &aKey, const String &aName); 85 86 virtual const TmSzHistStat *hist(const PhaseInfo &phase) const; 87 virtual const TmSzStat *trace(const StatIntvlRec &rec) const; 88 89 protected: 90 mutable TmSzHistStat theXactHist; 91 mutable TmSzStat theXactAggr; 92 93 virtual void describe(XmlNodes &nodes) const; 94 }; 95 96 97 class ValidationHitStex: public Stex { 98 public: 99 ValidationHitStex(const String &aKey, const String &aName, const HRHistPtr aHRHist); 100 101 virtual const TmSzStat *aggr(const PhaseInfo &phase) const; 102 virtual const TmSzHistStat *hist(const PhaseInfo &phase) const; 103 104 virtual void describe(XmlNodes &nodes) const; 105 106 protected: 107 mutable TmSzStat theXactAggr; 108 109 const HRHistPtr theHRHist; 110 }; 111 112 class ValidationMissStex: public Stex { 113 public: 114 ValidationMissStex(const String &aKey, const String &aName, const HRHistPtr aHRHist); 115 116 virtual const TmSzStat *aggr(const PhaseInfo &phase) const; 117 virtual const TmSzHistStat *hist(const PhaseInfo &phase) const; 118 119 virtual void describe(XmlNodes &nodes) const; 120 121 protected: 122 mutable TmSzStat theXactAggr; 123 124 const HRHistPtr theHRHist; 125 }; 126 127 class ValidationHitMissStex: public Stex { 128 public: 129 ValidationHitMissStex(const String &aKey, const String &aName, const HRHistPtr aHRHist, const TracePtr aTrace); 130 131 virtual const TmSzStat *aggr(const PhaseInfo &phase) const; 132 virtual const TmSzHistStat *hist(const PhaseInfo &phase) const; 133 virtual const TmSzStat *trace(const StatIntvlRec &rec) const; 134 135 virtual void describe(XmlNodes &nodes) const; 136 137 protected: 138 mutable TmSzHistStat theXactHist; 139 mutable TmSzStat theXactAggr; 140 141 const HRHistPtr theHRHist; 142 const TracePtr theTrace; 143 }; 144 145 146 class CachableStex: public Stex { 147 public: 148 CachableStex(const String &aKey, const String &aName); 149 150 virtual const TmSzStat *trace(const StatIntvlRec &rec) const; 151 152 virtual void describe(XmlNodes &nodes) const; 153 }; 154 155 class UnCachableStex: public Stex { 156 public: 157 UnCachableStex(const String &aKey, const String &aName); 158 159 virtual const TmSzStat *trace(const StatIntvlRec &rec) const; 160 161 virtual void describe(XmlNodes &nodes) const; 162 }; 163 164 class AllCachableStex: public Stex { 165 public: 166 AllCachableStex(const String &aKey, const String &aName); 167 168 virtual const TmSzStat *trace(const StatIntvlRec &rec) const; 169 170 virtual void describe(XmlNodes &nodes) const; 171 172 protected: 173 mutable TmSzStat theXactAggr; 174 }; 175 176 177 class FillStex: public Stex { 178 public: 179 FillStex(const String &aKey, const String &aName); 180 181 virtual const TmSzStat *trace(const StatIntvlRec &rec) const; 182 183 virtual void describe(XmlNodes &nodes) const; 184 }; 185 186 187 class SimpleStex: public Stex { 188 public: 189 SimpleStex(const String &aKey, const String &aName, HistPtr aHist, TracePtr aTrace); 190 191 virtual const TmSzHistStat *hist(const PhaseInfo &phase) const; 192 virtual const TmSzStat *trace(const StatIntvlRec &rec) const; 193 194 virtual void describe(XmlNodes &nodes) const; 195 196 protected: 197 HistPtr theHist; 198 TracePtr theTrace; 199 }; 200 201 202 class AllMethodsStex: public Stex { 203 204 public: 205 AllMethodsStex(const String &aKey, const String &aName); 206 207 virtual const TmSzHistStat *hist(const PhaseInfo &phase) const; 208 virtual const TmSzStat *trace(const StatIntvlRec &rec) const; 209 210 virtual void describe(XmlNodes &nodes) const; 211 212 protected: 213 mutable TmSzHistStat theXactHist; 214 mutable TmSzStat theXactAggr; 215 }; 216 217 218 class AllRepsStex: public Stex { 219 public: 220 AllRepsStex(const String &aKey, const String &aName); 221 222 virtual const TmSzHistStat *hist(const PhaseInfo &phase) const; 223 virtual const TmSzStat *trace(const StatIntvlRec &rec) const; 224 225 virtual void describe(XmlNodes &nodes) const; 226 227 protected: 228 mutable TmSzHistStat theXactHist; 229 mutable TmSzStat theXactAggr; 230 }; 231 232 233 class ContTypeStex: public Stex { 234 public: 235 virtual const TmSzHistStat *hist(const PhaseInfo &phase) const; 236 virtual const TmSzStat *trace(const StatIntvlRec &rec) const; 237 238 virtual void describe(XmlNodes &nodes) const; 239 240 protected: 241 ContTypeStex(const String &aKey, const String &aName, const int idx, const ContTypeAggrPtr aContTypeAggr, const ContTypeHistPtr aContTypeHist); 242 243 const int theIdx; 244 const ContTypeAggrPtr theContTypeAggr; 245 const ContTypeHistPtr theContTypeHist; 246 }; 247 248 class RepContTypeStex: public ContTypeStex { 249 public: 250 RepContTypeStex(const String &aKey, const String &aName, const int idx); 251 }; 252 253 class ReqContTypeStex: public ContTypeStex { 254 public: 255 ReqContTypeStex(const String &aKey, const String &aName, const int idx); 256 }; 257 258 259 class AllContTypesStex: public Stex { 260 public: 261 virtual const TmSzHistStat *hist(const PhaseInfo &phase) const; 262 virtual const TmSzStat *trace(const StatIntvlRec &rec) const; 263 264 virtual void describe(XmlNodes &nodes) const; 265 266 protected: 267 AllContTypesStex(const String &aKey, const String &aName, const ContTypeAggrPtr aContTypeAggr, const ContTypeHistPtr aContTypeHist); 268 269 const ContTypeAggrPtr theContTypeAggr; 270 const ContTypeHistPtr theContTypeHist; 271 mutable TmSzStat theAggrStat; 272 mutable TmSzHistStat theHistStat; 273 }; 274 275 class AllRepContTypesStex: public AllContTypesStex { 276 public: 277 AllRepContTypesStex(const String &aKey, const String &aName); 278 }; 279 280 class AllReqContTypesStex: public AllContTypesStex { 281 public: 282 AllReqContTypesStex(const String &aKey, const String &aName); 283 }; 284 285 286 class CompoundReplyStex: public Stex { 287 public: 288 CompoundReplyStex(const String &aKey, const String &aName, const CompoundPtr aCompoundPtr); 289 290 virtual const TmSzStat *aggr(const PhaseInfo &phase) const; 291 virtual const Histogram *partsHist(const PhaseInfo &phase) const; 292 293 virtual void describe(XmlNodes &nodes) const; 294 295 protected: 296 const CompoundPtr theCompoundPtr; 297 mutable TmSzStat theStat; 298 }; 299 300 class CompoundRequestStex: public Stex { 301 public: 302 CompoundRequestStex(const String &aKey, const String &aName, const CompoundPtr aCompoundPtr); 303 304 virtual const TmSzStat *aggr(const PhaseInfo &phase) const; 305 virtual const Histogram *partsHist(const PhaseInfo &phase) const; 306 307 virtual void describe(XmlNodes &nodes) const; 308 309 protected: 310 const CompoundPtr theCompoundPtr; 311 mutable TmSzStat theStat; 312 }; 313 314 class AllCompoundRepsStex: public Stex { 315 public: 316 AllCompoundRepsStex(const String &aKey, const String &aName); 317 318 virtual const TmSzStat *aggr(const PhaseInfo &phase) const; 319 virtual const Histogram *partsHist(const PhaseInfo &phase) const; 320 321 virtual void describe(XmlNodes &nodes) const; 322 323 protected: 324 mutable CompoundXactStat theCompound; 325 mutable TmSzStat theStat; 326 }; 327 328 class AllCompoundReqsStex: public Stex { 329 public: 330 AllCompoundReqsStex(const String &aKey, const String &aName); 331 332 virtual const TmSzStat *aggr(const PhaseInfo &phase) const; 333 virtual const Histogram *partsHist(const PhaseInfo &phase) const; 334 335 virtual void describe(XmlNodes &nodes) const; 336 337 protected: 338 mutable CompoundXactStat theCompound; 339 mutable TmSzStat theStat; 340 }; 341 342 343 class AuthIngStex: public Stex { 344 public: 345 AuthIngStex(const String &aKey, const String &aName, const AuthPhaseStat::Scheme aScheme); 346 347 virtual const TmSzStat *trace(const StatIntvlRec &rec) const; 348 349 virtual void describe(XmlNodes &nodes) const; 350 351 protected: 352 const AuthPhaseStat::Scheme theScheme; 353 }; 354 355 class AuthEdStex: public Stex { 356 public: 357 AuthEdStex(const String &aKey, const String &aName, const AuthPhaseStat::Scheme aScheme); 358 359 virtual const TmSzStat *trace(const StatIntvlRec &rec) const; 360 361 virtual void describe(XmlNodes &nodes) const; 362 363 protected: 364 const AuthPhaseStat::Scheme theScheme; 365 }; 366 367 368 class AllAuthIngStex: public Stex { 369 public: 370 AllAuthIngStex(const String &aKey, const String &aName); 371 372 virtual const TmSzStat *trace(const StatIntvlRec &rec) const; 373 374 virtual void describe(XmlNodes &nodes) const; 375 376 protected: 377 mutable TmSzStat theStat; 378 }; 379 380 class AllAuthEdStex: public Stex { 381 public: 382 AllAuthEdStex(const String &aKey, const String &aName); 383 384 virtual const TmSzStat *trace(const StatIntvlRec &rec) const; 385 386 virtual void describe(XmlNodes &nodes) const; 387 388 protected: 389 mutable TmSzStat theStat; 390 }; 391 392 class AllAuthStex: public Stex { 393 public: 394 AllAuthStex(const String &aKey, const String &aName); 395 396 virtual const TmSzStat *trace(const StatIntvlRec &rec) const; 397 398 virtual void describe(XmlNodes &nodes) const; 399 400 protected: 401 mutable TmSzStat theStat; 402 }; 403 404 405 class ProtoIntvlStex: public Stex { 406 public: 407 typedef ProtoIntvlStat StatIntvlRec::*ProtoPtr; 408 ProtoIntvlStex(ProtoPtr theProto, const String &aKey, const String &aName); 409 410 protected: 411 ProtoPtr theProto; 412 }; 413 414 class ProtoHitsStex: public ProtoIntvlStex { 415 public: 416 ProtoHitsStex(ProtoPtr theProto, const String &aKey, const String &aName); 417 418 virtual const TmSzStat *trace(const StatIntvlRec &rec) const; 419 420 virtual void describe(XmlNodes &nodes) const; 421 }; 422 423 class ProtoMissesStex: public ProtoIntvlStex { 424 public: 425 ProtoMissesStex(ProtoPtr theProto, const String &aKey, const String &aName); 426 427 virtual const TmSzStat *trace(const StatIntvlRec &rec) const; 428 429 virtual void describe(XmlNodes &nodes) const; 430 }; 431 432 class ProtoHitMissesStex: public ProtoIntvlStex { 433 public: 434 ProtoHitMissesStex(ProtoPtr theProto, const String &aKey, const String &aName); 435 436 virtual const TmSzStat *trace(const StatIntvlRec &rec) const; 437 438 protected: 439 mutable TmSzStat theAggr; 440 441 virtual void describe(XmlNodes &nodes) const; 442 }; 443 444 class CookiesStex: public Stex { 445 public: 446 CookiesStex(const String &aKey, const String &aName, const AggrPtr anAggrPtr); 447 448 virtual const AggrStat *partsStat(const PhaseInfo &phase) const; 449 450 protected: 451 const AggrPtr theAggrPtr; 452 453 virtual void describe(XmlNodes &nodes) const; 454 }; 455 456 class AllStatusCodeStex: public Stex { 457 public: 458 AllStatusCodeStex(const String &aKey, const String &aName, const StatusCodePtr aPtr); 459 460 virtual const TmSzStat *aggr(const PhaseInfo &phase) const; 461 462 virtual void describe(XmlNodes &nodes) const; 463 464 protected: 465 const StatusCodePtr thePtr; 466 mutable TmSzStat theAggr; 467 }; 468 469 class StatusCodeStex: public Stex { 470 public: 471 StatusCodeStex(const String &aKey, const String &aName, const StatusCodePtr aPtr, const int aStatus); 472 473 virtual const TmSzStat *aggr(const PhaseInfo &phase) const; 474 475 virtual void describe(XmlNodes &nodes) const; 476 477 protected: 478 const StatusCodePtr thePtr; 479 const int theStatus; 480 }; 481 482 #endif 483