Stats tree seems to work properly, including pruning of "empty" leaves
diff --git a/utils/load-stats.cc b/utils/load-stats.cc
index ee61df4..8a663e3 100644
--- a/utils/load-stats.cc
+++ b/utils/load-stats.cc
@@ -19,6 +19,7 @@
*/
#include "load-stats.h"
+#include "ns3/log.h"
using namespace ns3;
@@ -28,6 +29,8 @@
const double EPSILON = 0.000001;
+NS_LOG_COMPONENT_DEFINE ("LoadStats");
+
namespace ndnSIM
{
@@ -42,6 +45,8 @@
void
LoadStats::Step ()
{
+ // NS_LOG_FUNCTION (this);
+
// do magic
avg1_ = EXP_1 * avg1_ + (1 - EXP_1) * counter_;
avg5_ = EXP_1 * avg5_ + (1 - EXP_5) * counter_;
@@ -53,25 +58,17 @@
LoadStats &
LoadStats::operator ++ (int)
{
+ // NS_LOG_FUNCTION (this);
+
counter_ ++;
return *this;
}
-// void
-// LoadStats::Increment (uint32_t amount)
-// {
-// counter_ += amount;
-// }
-
-// uint32_t
-// LoadStats::GetCounter () const
-// {
-// return counter_;
-// }
-
LoadStats &
LoadStats::operator += (const LoadStats &stats)
{
+ // NS_LOG_FUNCTION (this << &stats << stats.counter_);
+
counter_ += stats.counter_;
return *this;
}
@@ -83,9 +80,10 @@
}
bool
-LoadStats::IsEmpty () const
+LoadStats::IsZero () const
{
- return (avg1_ < EPSILON &&
+ return (counter_ == 0 &&
+ avg1_ < EPSILON &&
avg5_ < EPSILON &&
avg15_ < EPSILON);
}
@@ -93,8 +91,7 @@
std::ostream &
operator << (std::ostream &os, const LoadStats &stats)
{
- LoadStats::stats_tuple data = stats.GetStats ();
- os << data.get<0> () << ", " << data.get<1> () << ", " << data.get<2> ();// << std::endl;
+ os << stats.avg1_ << ", " << stats.avg5_ << ", " << stats.avg15_;
return os;
}