GlobalStatistics Class Reference

Modul to record global statistics. More...

#include <GlobalStatistics.h>

List of all members.

Classes

struct  OutVector
 < struct for cOutVectors and cummulated values More...

Public Member Functions

 ~GlobalStatistics ()
 Destructor.
void addStdDev (const std::string &name, double value)
 Add a new value to the cStdDev container specified by the name parameter.
void recordOutVector (const std::string &name, double value)
 record a value to a global cOutVector defined by name
void startMeasuring ()
bool isMeasuring ()
simtime_t getMeasureStartTime ()
simtime_t calcMeasuredLifetime (simtime_t creationTime)
void finalizeStatistics ()

Public Attributes

double sentKBRTestAppMessages
 total number of messages sent by KBRTestApp
double deliveredKBRTestAppMessages
 total number of messages delivered by KBRTestApp
int testCount
cOutVector currentDeliveryVector
 statistical output vector for current delivery ratio

Static Public Attributes

static const double MIN_MEASURED = 0.1
 minimum useful measured lifetime in seconds

Protected Member Functions

virtual void initialize ()
 Init member function of module.
virtual void handleMessage (cMessage *msg)
 HandleMessage member function of module.
virtual void finish ()
 Finish member function of module.

Protected Attributes

std::map< std::string, cStdDev * > stdDevMap
 map to store and access the statistics data
std::map< std::string,
OutVector * > 
outVectorMap
 map to store and access the output vectors
cMessage * globalStatTimer
 timer for periodic statistic updates
double globalStatTimerInterval
 interval length of periodic statistic timer
bool measuring
simtime_t measureStartTime

Detailed Description

Modul to record global statistics.

Author:
Ingmar Baumgart

Definition at line 50 of file GlobalStatistics.h.


Constructor & Destructor Documentation

GlobalStatistics::~GlobalStatistics (  ) 

Destructor.

Definition at line 213 of file GlobalStatistics.cc.

00214 {
00215     // deallocate vectors
00216     for (map<std::string, cStdDev*>::iterator iter = stdDevMap.begin();
00217     iter != stdDevMap.end(); iter++) {
00218         delete iter->second;
00219     }
00220     stdDevMap.clear();
00221 
00222     for (map<std::string, OutVector*>::iterator iter = outVectorMap.begin();
00223     iter != outVectorMap.end(); iter++) {
00224         delete iter->second;
00225     }
00226     outVectorMap.clear();
00227 }


Member Function Documentation

void GlobalStatistics::addStdDev ( const std::string &  name,
double  value 
)

Add a new value to the cStdDev container specified by the name parameter.

If the container does not exist yet, a new container is created

Parameters:
name a string to identify the container (should be "Module: Scalar Name")
value the value to add

Definition at line 136 of file GlobalStatistics.cc.

Referenced by Nps::coordsReqRpcResponse(), SimpleUDP::finish(), CryptoModule::finish(), BaseOverlay::finish(), BaseApp::finish(), SimMud::finishApp(), Scribe::finishApp(), P2PNSTestApp::finishApp(), NeighborCache::finishApp(), MyApplication::finishApp(), KBRTestApp::finishApp(), GIASearchApp::finishApp(), DHTTestApp::finishApp(), DHT::finishApp(), CBRDHT::finishApp(), Vast::finishOverlay(), Quon::finishOverlay(), PubSubMMOG::finishOverlay(), PubSubLobby::finishOverlay(), MyOverlay::finishOverlay(), oversim::Koorde::finishOverlay(), Kademlia::finishOverlay(), Gia::finishOverlay(), oversim::Chord::finishOverlay(), Broose::finishOverlay(), BasePastry::finishOverlay(), Vivaldi::finishVivaldi(), DHTTestApp::handleGetResponse(), ConnectivityProbeQuon::handleMessage(), ConnectivityProbeApp::handleMessage(), ConnectivityProbe::handleMessage(), PubSubMMOG::handleMoveListMessage(), Vast::handleNodeMove(), Quon::handleNodeMove(), SimMud::handleOtherPlayerMove(), and DHTTestApp::handlePutResponse().

00137 {
00138     if (!measuring) {
00139         return;
00140     }
00141 
00142     std::map<std::string, cStdDev*>::iterator sdPos = stdDevMap.find(name);
00143     cStdDev* sd = NULL;
00144 
00145     if (sdPos == stdDevMap.end()) {
00146         Enter_Method_Silent();
00147         sd = new cStdDev(name.c_str());
00148         stdDevMap.insert(pair<std::string, cStdDev*>(name, sd));
00149     } else {
00150         sd = sdPos->second;
00151     }
00152 
00153     sd->collect(value);
00154 }

simtime_t GlobalStatistics::calcMeasuredLifetime ( simtime_t  creationTime  ) 
void GlobalStatistics::finalizeStatistics (  ) 

Definition at line 103 of file GlobalStatistics.cc.

00104 {
00105     recordScalar("GlobalStatistics: Simulation Time", simTime());
00106 
00107     bool outputMinMax = par("outputMinMax");
00108     bool outputStdDev = par("outputStdDev");
00109 
00110     // record stats from other modules
00111     for (map<std::string, cStdDev*>::iterator iter = stdDevMap.begin();
00112     iter != stdDevMap.end(); iter++) {
00113 
00114         const std::string& n = iter->first;
00115         const cStatistic& stat = *(iter->second);
00116 
00117         recordScalar((n + ".mean").c_str(), stat.getMean());
00118 
00119         if (outputStdDev)
00120             recordScalar((n + ".stddev").c_str(), stat.getStddev());
00121 
00122         if (outputMinMax) {
00123             recordScalar((n + ".min").c_str(), stat.getMin());
00124             recordScalar((n + ".max").c_str(), stat.getMax());
00125         }
00126     }
00127 
00128     for (map<std::string, OutVector*>::iterator iter = outVectorMap.begin();
00129     iter != outVectorMap.end(); iter++) {
00130         const OutVector& ov = *(iter->second);
00131         double mean = ov.count > 0 ? ov.value / ov.count : 0;
00132         recordScalar(("Vector: " + iter->first + ".mean").c_str(), mean);
00133     }
00134 }

void GlobalStatistics::finish (  )  [protected, virtual]

Finish member function of module.

Definition at line 92 of file GlobalStatistics.cc.

00093 {
00094     // Here, the FinisherModule is created which will get destroyed at last.
00095     // This way, all other modules have sent their statistical data to the
00096     // GobalStatisticModule before GlobalStatistics::finalizeStatistics()
00097     // is called by FinisherModule::finish()
00098     cModuleType* moduleType = cModuleType::get("oversim.common.FinisherModule");
00099     moduleType->create("finisherModule", getParentModule()->getParentModule());
00100 }

simtime_t GlobalStatistics::getMeasureStartTime (  )  [inline]

Definition at line 86 of file GlobalStatistics.h.

00086 { return measureStartTime; };

void GlobalStatistics::handleMessage ( cMessage *  msg  )  [protected, virtual]

HandleMessage member function of module.

Definition at line 64 of file GlobalStatistics.cc.

00065 {
00066     if (msg == globalStatTimer) {
00067         // schedule next timer event
00068         scheduleAt(simTime() + globalStatTimerInterval, msg);
00069 
00070         double ratio;
00071 
00072         // quick hack for live display of the current KBR delivery ratio
00073         if (sentKBRTestAppMessages == 0) {
00074             ratio = 0;
00075         } else {
00076             ratio = (double)deliveredKBRTestAppMessages /
00077             (double)sentKBRTestAppMessages;
00078         }
00079 
00080         if (ratio > 1) ratio = 1;
00081 
00082         currentDeliveryVector.record(ratio);
00083         sentKBRTestAppMessages = 0;
00084         deliveredKBRTestAppMessages = 0;
00085 
00086         return;
00087     }
00088 
00089     error("GlobalStatistics::handleMessage(): Unknown message type!");
00090 }

void GlobalStatistics::initialize (  )  [protected, virtual]

Init member function of module.

Definition at line 32 of file GlobalStatistics.cc.

00033 {
00034     sentKBRTestAppMessages = 0;
00035     deliveredKBRTestAppMessages = 0;
00036 
00037     measuring = par("measureNetwInitPhase");
00038     measureStartTime = 0;
00039 
00040     currentDeliveryVector.setName("Current Delivery Ratio");
00041 
00042     // start periodic globalStatTimer
00043     globalStatTimerInterval = par("globalStatTimerInterval");
00044 
00045     if (globalStatTimerInterval > 0) {
00046         globalStatTimer = new cMessage("globalStatTimer");
00047         scheduleAt(simTime() + globalStatTimerInterval, globalStatTimer);
00048     }
00049 
00050     WATCH(measuring);
00051     WATCH(measureStartTime);
00052     WATCH(currentDeliveryVector);
00053 }

bool GlobalStatistics::isMeasuring (  )  [inline]
void GlobalStatistics::recordOutVector ( const std::string &  name,
double  value 
)

record a value to a global cOutVector defined by name

Parameters:
name a string to identify the vector (should be "Module: Scalar Name")
value the value to add

Definition at line 156 of file GlobalStatistics.cc.

Referenced by NeighborCache::calcRttError(), ParetoChurn::createNode(), LifetimeChurn::createNode(), ParetoChurn::deleteNode(), LifetimeChurn::deleteNode(), KBRTestApp::evaluateData(), Landmark::finishApp(), Kademlia::handleBucketRefreshTimerExpired(), KBRTestApp::handleLookupResponse(), GlobalNodeList::handleMessage(), GlobalDhtTestMap::handleMessage(), KBRTestApp::handleRpcResponse(), KBRTestApp::handleRpcTimeout(), and ParetoChurn::initializeChurn().

00158 {
00159     if (!measuring) {
00160         return;
00161     }
00162 
00163     std::map<std::string, OutVector*>::iterator ovPos =
00164         outVectorMap.find(name);
00165     OutVector* ov = NULL;
00166 
00167     if (ovPos == outVectorMap.end()) {
00168         Enter_Method_Silent();
00169         ov = new OutVector(name);
00170         outVectorMap.insert(pair<std::string, OutVector*>(name, ov));
00171     } else {
00172         ov = ovPos->second;
00173     }
00174 
00175     ov->vector.record(value);
00176     ov->value += value;
00177     ov->count++;
00178 
00179 #if 0
00180     // avg vector
00181     if (avg != -1) {
00182         std::string name_avg = name + "_avg";
00183         std::map<std::string, OutVector*>::iterator ovPos_avg =
00184             outVectorMap.find(name_avg);
00185         OutVector* ov_avg = NULL;
00186 
00187         if (ovPos_avg == outVectorMap.end()) {
00188             Enter_Method_Silent();
00189             ov_avg = new OutVector(name_avg);
00190             outVectorMap.insert(pair<std::string, OutVector*>(name_avg, ov_avg));
00191         } else {
00192             ov_avg = ovPos_avg->second;
00193         }
00194         int div = ((ov_avg->count >= avg) ? (avg - 1) : ov_avg->count);
00195         if (div <= 0) div = 1;
00196 
00197         double newValue = (ov_avg->avg * div + value) / (div + 1);
00198         ov_avg->vector.record(newValue);
00199         ov_avg->avg = newValue;
00200         ov_avg->value += newValue;
00201         ov_avg->count++;
00202     }
00203 #endif
00204 
00205 }

void GlobalStatistics::startMeasuring (  ) 

Definition at line 55 of file GlobalStatistics.cc.

Referenced by UnderlayConfigurator::handleMessage().

00056 {
00057     if (!measuring) {
00058         measuring = true;
00059         measureStartTime = simTime();
00060     }
00061 }


Member Data Documentation

statistical output vector for current delivery ratio

Definition at line 58 of file GlobalStatistics.h.

Referenced by handleMessage(), and initialize().

total number of messages delivered by KBRTestApp

Definition at line 56 of file GlobalStatistics.h.

Referenced by KBRTestApp::evaluateData(), handleMessage(), and initialize().

cMessage* GlobalStatistics::globalStatTimer [protected]

timer for periodic statistic updates

Definition at line 107 of file GlobalStatistics.h.

Referenced by handleMessage(), and initialize().

interval length of periodic statistic timer

Definition at line 108 of file GlobalStatistics.h.

Referenced by handleMessage(), and initialize().

simtime_t GlobalStatistics::measureStartTime [protected]
bool GlobalStatistics::measuring [protected]
const double GlobalStatistics::MIN_MEASURED = 0.1 [static]
std::map<std::string, OutVector*> GlobalStatistics::outVectorMap [protected]

map to store and access the output vectors

Definition at line 106 of file GlobalStatistics.h.

Referenced by finalizeStatistics(), recordOutVector(), and ~GlobalStatistics().

total number of messages sent by KBRTestApp

Definition at line 55 of file GlobalStatistics.h.

Referenced by handleMessage(), KBRTestApp::handleTimerEvent(), and initialize().

std::map<std::string, cStdDev*> GlobalStatistics::stdDevMap [protected]

map to store and access the statistics data

Definition at line 105 of file GlobalStatistics.h.

Referenced by addStdDev(), finalizeStatistics(), and ~GlobalStatistics().

Definition at line 57 of file GlobalStatistics.h.


The documentation for this class was generated from the following files:
Generated on Wed May 26 16:21:17 2010 for OverSim by  doxygen 1.6.3