calc min/max of the individual avgs for rank > 1
[senf.git] / senf / Utils / Statistics.cc
index a96b33b..0d5e947 100644 (file)
@@ -28,7 +28,7 @@
 
 // Custom includes
 #include <sstream>
-#include "Console/Console.hh"
+#include <senf/Utils/Console/Console.hh>
 #include "StatisticsTargets.hh"
 
 //#include "Statistics.mpp"
@@ -81,23 +81,23 @@ senf::StatisticsBase::output(unsigned n)
 }
 
 //
-// generate an engineering style notation i
+// generate an engineering style notation 
 //
 char *format_eng( float f)
 {
     static char buf[16];
-    if( f > 0){
+    if (f > 0) {
         int n = 0;
-        while( f >= 1000.0f){
+        while( f >= 1000.0f) {
                 f /= 1000.f;
                 n+=3;
         }
 
         sprintf( buf, " %3.2fe%+03d", f, n);
     }
-    else if( f < 0){
+    else if (f < 0) {
         int n = 0;
-        while( f <= -1000.0f){
+        while( f <= -1000.0f) {
                 f *= 1000.f;
                 n+=3;
         }
@@ -287,10 +287,17 @@ prefix_ std::string senf::Statistics::v_path()
 prefix_ void senf::Collector::enter(float min, float avg, float max)
 {
     accAvg_ += avg;
-    if (min < accMin_) accMin_ = min;
-    if (max > accMax_) accMax_ = max;
+    if (avg < accMin_) accMin_ = avg;
+    if (avg > accMax_) accMax_ = avg;
     if (++i_ >= rank_) {
-        StatisticsBase::enter(accMin_, accAvg_ / rank_, accMax_);
+       if( i_ == 1){
+         // no averaging, report min & max for this period
+          StatisticsBase::enter(min, avg, max);
+       }
+       else{
+         // averaging, report min(avgs) and max(avgs)
+         StatisticsBase::enter(accMin_, accAvg_ / rank_, accMax_);
+       } 
         i_ = 0;
         accMin_ = FLT_MAX;
         accAvg_ = 0.0f;