stats: this makes some fixes to AverageStat and AverageVector.

Also, make Formulas work on AverageVector.  First, Stat::Average (and thus
Stats::AverageVector) was broken when coming out of a checkpoint and on resets,
this fixes that.  Formulas also didn't work with AverageVector, but added
support for that.
This commit is contained in:
Lisa Hsu 2010-02-23 09:33:18 -08:00
parent 2ad386f104
commit be4cf50c5a
2 changed files with 10 additions and 2 deletions

View file

@ -492,6 +492,8 @@ class AvgStor
private:
/** The current count. */
Counter current;
/** The tick of the last reset */
Tick lastReset;
/** The total count for all tick. */
mutable Result total;
/** The tick that current last changed. */
@ -505,7 +507,7 @@ class AvgStor
* Build and initializes this stat storage.
*/
AvgStor(Info *info)
: current(0), total(0), last(0)
: current(0), lastReset(0), total(0), last(0)
{ }
/**
@ -547,7 +549,7 @@ class AvgStor
result() const
{
assert(last == curTick);
return (Result)(total + current) / (Result)(curTick + 1);
return (Result)(total + current) / (Result)(curTick - lastReset + 1);
}
/**
@ -573,6 +575,7 @@ class AvgStor
{
total = 0.0;
last = curTick;
lastReset = curTick;
}
};
@ -2551,6 +2554,10 @@ class Temp
: node(new VectorStatNode(s.info()))
{ }
Temp(const AverageVector &s)
: node(new VectorStatNode(s.info()))
{ }
/**
*
*/

View file

@ -148,6 +148,7 @@ def restoreCheckpoint(root, dir):
print "Restoring from checkpoint"
internal.core.unserializeAll(dir)
need_resume.append(root)
stats.reset()
def changeToAtomic(system):
if not isinstance(system, (objects.Root, objects.System)):