GlobalStatistics.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2007 Institut fuer Telematik, Universitaet Karlsruhe (TH)
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // of the License, or (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 //
00018 
00024 #ifndef __GLOBALSTATISTICS_H__
00025 #define __GLOBALSTATISTICS_H__
00026 
00027 #include <map>
00028 
00029 #include <omnetpp.h>
00030 
00031 class OverlayKey;
00032 
00038 #define RECORD_STATS(x) \
00039     do { \
00040         if (globalStatistics->isMeasuring()){ x; } \
00041     } while(false)
00042 
00043 
00044 
00050 class GlobalStatistics : public cSimpleModule
00051 {
00052 public:
00053     static const double MIN_MEASURED = 0.1; 
00054 
00055     double sentKBRTestAppMessages; 
00056     double deliveredKBRTestAppMessages; 
00057     int testCount;
00058     cOutVector currentDeliveryVector; 
00059 
00060     int nodesInitialized; 
00061     int nodesFinished; 
00062 
00066     ~GlobalStatistics();
00067 
00072     void doFinish();
00073 
00081     void addStdDev(const std::string& name, double value);
00082 
00083 
00090     void recordOutVector(const std::string& name, double value /*, int avg = -1*/);
00091 
00092     void startMeasuring();
00093 
00094     inline bool isMeasuring() { return measuring; };
00095     inline simtime_t getMeasureStartTime() { return measureStartTime; };
00096 
00097     simtime_t calcMeasuredLifetime(simtime_t creationTime);
00098 
00099 protected:
00100 
00101     struct OutVector 
00102     {
00103         cOutVector vector; 
00104         int count; 
00105         double value; 
00106         double avg;
00107 
00108         OutVector(const std::string& name) :
00109             vector(name.c_str()), count(0), value(0), avg(0) {};
00110     };
00111 
00112     std::map<std::string, cStdDev*> stdDevMap; 
00113     std::map<std::string, OutVector*> outVectorMap; 
00114     cMessage* globalStatTimer; 
00115     double globalStatTimerInterval; 
00116 
00120     virtual void initialize();
00121 
00125     virtual void handleMessage(cMessage* msg);
00126 
00130     virtual void finish();
00131 
00132     bool measuring;
00133     simtime_t measureStartTime;
00134 };
00135 
00136 #endif

Generated on Tue Sep 8 17:26:52 2009 for OverSim by  doxygen 1.5.8