statistics.hh (7811:a8fc35183c10) | statistics.hh (7823:dac01f14f20f) |
---|---|
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; --- 58 unchanged lines hidden (view full) --- 67#include "base/stats/types.hh" 68#include "base/stats/visit.hh" 69#include "base/str.hh" 70#include "base/types.hh" 71 72class Callback; 73 74/** The current simulated tick. */ | 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; --- 58 unchanged lines hidden (view full) --- 67#include "base/stats/types.hh" 68#include "base/stats/visit.hh" 69#include "base/str.hh" 70#include "base/types.hh" 71 72class Callback; 73 74/** The current simulated tick. */ |
75extern Tick curTick; | 75extern Tick curTick(); |
76 77/* A namespace for all of the Statistics */ 78namespace Stats { 79 80template <class Stat, class Base> 81class InfoProxy : public Base 82{ 83 protected: --- 441 unchanged lines hidden (view full) --- 525 /** 526 * Set the current count to the one provided, update the total and last 527 * set values. 528 * @param val The new count. 529 */ 530 void 531 set(Counter val) 532 { | 76 77/* A namespace for all of the Statistics */ 78namespace Stats { 79 80template <class Stat, class Base> 81class InfoProxy : public Base 82{ 83 protected: --- 441 unchanged lines hidden (view full) --- 525 /** 526 * Set the current count to the one provided, update the total and last 527 * set values. 528 * @param val The new count. 529 */ 530 void 531 set(Counter val) 532 { |
533 total += current * (curTick - last); 534 last = curTick; | 533 total += current * (curTick() - last); 534 last = curTick(); |
535 current = val; 536 } 537 538 /** 539 * Increment the current count by the provided value, calls set. 540 * @param val The amount to increment. 541 */ 542 void inc(Counter val) { set(current + val); } --- 12 unchanged lines hidden (view full) --- 555 556 /** 557 * Return the current average. 558 * @return The current average. 559 */ 560 Result 561 result() const 562 { | 535 current = val; 536 } 537 538 /** 539 * Increment the current count by the provided value, calls set. 540 * @param val The amount to increment. 541 */ 542 void inc(Counter val) { set(current + val); } --- 12 unchanged lines hidden (view full) --- 555 556 /** 557 * Return the current average. 558 * @return The current average. 559 */ 560 Result 561 result() const 562 { |
563 assert(last == curTick); 564 return (Result)(total + current) / (Result)(curTick - lastReset + 1); | 563 assert(last == curTick()); 564 return (Result)(total + current) / (Result)(curTick() - lastReset + 1); |
565 } 566 567 /** 568 * @return true if zero value 569 */ 570 bool zero() const { return total == 0.0; } 571 572 /** 573 * Prepare stat data for dumping or serialization 574 */ 575 void 576 prepare(Info *info) 577 { | 565 } 566 567 /** 568 * @return true if zero value 569 */ 570 bool zero() const { return total == 0.0; } 571 572 /** 573 * Prepare stat data for dumping or serialization 574 */ 575 void 576 prepare(Info *info) 577 { |
578 total += current * (curTick - last); 579 last = curTick; | 578 total += current * (curTick() - last); 579 last = curTick(); |
580 } 581 582 /** 583 * Reset stat value to default 584 */ 585 void 586 reset(Info *info) 587 { 588 total = 0.0; | 580 } 581 582 /** 583 * Reset stat value to default 584 */ 585 void 586 reset(Info *info) 587 { 588 total = 0.0; |
589 last = curTick; 590 lastReset = curTick; | 589 last = curTick(); 590 lastReset = curTick(); |
591 } 592 593}; 594 595/** 596 * Implementation of a scalar stat. The type of stat is determined by the 597 * Storage template. 598 */ --- 972 unchanged lines hidden (view full) --- 1571 prepare(Info *info, DistData &data) 1572 { 1573 const Params *params = safe_cast<const Params *>(info->storageParams); 1574 1575 assert(params->type == Deviation); 1576 data.type = params->type; 1577 data.sum = sum; 1578 data.squares = squares; | 591 } 592 593}; 594 595/** 596 * Implementation of a scalar stat. The type of stat is determined by the 597 * Storage template. 598 */ --- 972 unchanged lines hidden (view full) --- 1571 prepare(Info *info, DistData &data) 1572 { 1573 const Params *params = safe_cast<const Params *>(info->storageParams); 1574 1575 assert(params->type == Deviation); 1576 data.type = params->type; 1577 data.sum = sum; 1578 data.squares = squares; |
1579 data.samples = curTick; | 1579 data.samples = curTick(); |
1580 } 1581 1582 /** 1583 * Reset stat value to default 1584 */ 1585 void 1586 reset(Info *info) 1587 { --- 1202 unchanged lines hidden --- | 1580 } 1581 1582 /** 1583 * Reset stat value to default 1584 */ 1585 void 1586 reset(Info *info) 1587 { --- 1202 unchanged lines hidden --- |