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;

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

487 * being watched. This is good for keeping track of residencies in structures
488 * among other things.
489 */
490class AvgStor
491{
492 private:
493 /** The current count. */
494 Counter current;
495 /** The tick of the last reset */
496 Tick lastReset;
497 /** The total count for all tick. */
498 mutable Result total;
499 /** The tick that current last changed. */
500 mutable Tick last;
501
502 public:
503 struct Params : public StorageParams {};
504
505 public:
506 /**
507 * Build and initializes this stat storage.
508 */
509 AvgStor(Info *info)
508 : current(0), total(0), last(0)
510 : current(0), lastReset(0), total(0), last(0)
511 { }
512
513 /**
514 * Set the current count to the one provided, update the total and last
515 * set values.
516 * @param val The new count.
517 */
518 void

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

544 /**
545 * Return the current average.
546 * @return The current average.
547 */
548 Result
549 result() const
550 {
551 assert(last == curTick);
550 return (Result)(total + current) / (Result)(curTick + 1);
552 return (Result)(total + current) / (Result)(curTick - lastReset + 1);
553 }
554
555 /**
556 * @return true if zero value
557 */
558 bool zero() const { return total == 0.0; }
559
560 /**

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

570 /**
571 * Reset stat value to default
572 */
573 void
574 reset(Info *info)
575 {
576 total = 0.0;
577 last = curTick;
578 lastReset = curTick;
579 }
580
581};
582
583/**
584 * Implementation of a scalar stat. The type of stat is determined by the
585 * Storage template.
586 */

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

2549 /**
2550 * Create a new VectorStatNode.
2551 * @param s The VectorStat to place in a node.
2552 */
2553 Temp(const Vector &s)
2554 : node(new VectorStatNode(s.info()))
2555 { }
2556
2557 Temp(const AverageVector &s)
2558 : node(new VectorStatNode(s.info()))
2559 { }
2560
2561 /**
2562 *
2563 */
2564 Temp(const Formula &f)
2565 : node(new FormulaNode(f))
2566 { }
2567
2568 /**

--- 193 unchanged lines hidden ---