#include <GlobalStatistics.h>
Definition at line 49 of file GlobalStatistics.h.
Public Member Functions | |
| ~GlobalStatistics () | |
| Destructor. | |
| void | doFinish () |
| Do the actual finish() call and record scalars needed because finish() gets called before all nodes have transmitted their data to GlobalStatistics. | |
| void | addStdDev (const std::string &name, double value) |
| add a value to a cStdDev | |
| void | recordOutVector (const std::string &name, double value, int avg=-1) |
| record a value to a global cOutVector defined by name | |
| void | startMeasuring () |
| bool | isMeasuring () |
| simtime_t | getMeasureStartTime () |
| simtime_t | calcMeasuredLifetime (simtime_t creationTime) |
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 | |
| int | nodesInitialized |
| nodes that have run initialize() and "registered" with GlobalStatistics | |
| int | nodesFinished |
| nodes that have run finished() and have "deregistered" with GlobalStatistics | |
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 |
Classes | |
| struct | OutVector |
| < struct for cOutVectors and cummulated values More... | |
| GlobalStatistics::~GlobalStatistics | ( | ) |
Destructor.
Definition at line 211 of file GlobalStatistics.cc.
00212 { 00213 // deallocate vectors 00214 for (map<std::string, cStdDev*>::iterator iter = stdDevMap.begin(); 00215 iter != stdDevMap.end(); iter++) { 00216 delete iter->second; 00217 } 00218 stdDevMap.clear(); 00219 00220 for (map<std::string, OutVector*>::iterator iter = outVectorMap.begin(); 00221 iter != outVectorMap.end(); iter++) { 00222 delete iter->second; 00223 } 00224 outVectorMap.clear(); 00225 }
| void GlobalStatistics::doFinish | ( | ) |
Do the actual finish() call and record scalars needed because finish() gets called before all nodes have transmitted their data to GlobalStatistics.
Definition at line 99 of file GlobalStatistics.cc.
Referenced by finish(), and BaseOverlay::finish().
00100 { 00101 if (nodesInitialized != nodesFinished) return; 00102 00103 recordScalar("GlobalStatistics: Simulation Time", simTime()); 00104 00105 bool outputMinMax = par("outputMinMax"); 00106 bool outputStdDev = par("outputStdDev"); 00107 00108 // record stats from other modules 00109 for (map<std::string, cStdDev*>::iterator iter = stdDevMap.begin(); 00110 iter != stdDevMap.end(); iter++) { 00111 00112 const std::string& n = iter->first; 00113 const cStatistic& stat = *(iter->second); 00114 00115 recordScalar((n + ".mean").c_str(), stat.getMean()); 00116 00117 if (outputStdDev) 00118 recordScalar((n + ".stddev").c_str(), stat.getStddev()); 00119 00120 if (outputMinMax) { 00121 recordScalar((n + ".min").c_str(), stat.getMin()); 00122 recordScalar((n + ".max").c_str(), stat.getMax()); 00123 } 00124 } 00125 00126 for (map<std::string, OutVector*>::iterator iter = outVectorMap.begin(); 00127 iter != outVectorMap.end(); iter++) { 00128 00129 const OutVector& ov = *(iter->second); 00130 00131 double mean = ov.count > 0 ? ov.value / ov.count : 0; 00132 00133 recordScalar(("Vector: " + iter->first + ".mean").c_str(), mean); 00134 } 00135 }
| void GlobalStatistics::addStdDev | ( | const std::string & | name, | |
| double | value | |||
| ) |
add a value to a cStdDev
Definition at line 137 of file GlobalStatistics.cc.
Referenced by SimpleUDP::finish(), NeighborCache::finish(), BaseOverlay::finish(), BaseApp::finish(), SimMud::finishApp(), Scribe::finishApp(), KBRTestApp::finishApp(), GIASearchApp::finishApp(), DHTTestApp::finishApp(), DHT::finishApp(), Vast::finishOverlay(), QuonPR::finishOverlay(), QuonP::finishOverlay(), PubSubMMOG::finishOverlay(), PubSubLobby::finishOverlay(), oversim::Koorde::finishOverlay(), Kademlia::finishOverlay(), Gia::finishOverlay(), oversim::Chord::finishOverlay(), Broose::finishOverlay(), BasePastry::finishOverlay(), Vivaldi::finishVivaldi(), DHTTestApp::handleGetResponse(), ConnectivityProbePR::handleMessage(), ConnectivityProbeP::handleMessage(), ConnectivityProbe::handleMessage(), PubSubMMOG::handleMoveListMessage(), Vast::handleNodeMove(), SimMud::handleOtherPlayerMove(), and DHTTestApp::handlePutResponse().
00138 { 00139 if (!measuring) { 00140 return; 00141 } 00142 00143 std::map<std::string, cStdDev*>::iterator sdPos = stdDevMap.find(name); 00144 cStdDev* sd = NULL; 00145 00146 if (sdPos == stdDevMap.end()) { 00147 Enter_Method_Silent(); 00148 sd = new cStdDev(name.c_str()); 00149 stdDevMap.insert(pair<std::string, cStdDev*>(name, sd)); 00150 } else { 00151 sd = sdPos->second; 00152 } 00153 00154 sd->collect(value); 00155 }
| void GlobalStatistics::recordOutVector | ( | const std::string & | name, | |
| double | value, | |||
| int | avg = -1 | |||
| ) |
record a value to a global cOutVector defined by name
Definition at line 157 of file GlobalStatistics.cc.
Referenced by ParetoChurn::createNode(), LifetimeChurn::createNode(), ParetoChurn::deleteNode(), LifetimeChurn::deleteNode(), KBRTestApp::evaluateData(), GlobalNodeList::handleMessage(), GlobalDhtTestMap::handleMessage(), and ParetoChurn::initializeChurn().
00159 { 00160 if (!measuring) { 00161 return; 00162 } 00163 00164 std::map<std::string, OutVector*>::iterator ovPos = 00165 outVectorMap.find(name); 00166 OutVector* ov = NULL; 00167 00168 if (ovPos == outVectorMap.end()) { 00169 Enter_Method_Silent(); 00170 ov = new OutVector(name); 00171 outVectorMap.insert(pair<std::string, OutVector*>(name, ov)); 00172 } else { 00173 ov = ovPos->second; 00174 } 00175 00176 ov->vector.record(value); 00177 ov->value += value; 00178 ov->count++; 00179 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 }
| void GlobalStatistics::startMeasuring | ( | ) |
Definition at line 57 of file GlobalStatistics.cc.
Referenced by UnderlayConfigurator::handleMessage().
00058 { 00059 if (!measuring) { 00060 measuring = true; 00061 measureStartTime = simTime(); 00062 } 00063 }
| bool GlobalStatistics::isMeasuring | ( | ) | [inline] |
Definition at line 85 of file GlobalStatistics.h.
Referenced by KBRTestApp::handleTimerEvent(), DHTTestApp::handleTimerEvent(), and DHTTestApp::handleTraceMessage().
00085 { return measuring; };
| simtime_t GlobalStatistics::getMeasureStartTime | ( | ) | [inline] |
| simtime_t GlobalStatistics::calcMeasuredLifetime | ( | simtime_t | creationTime | ) |
Definition at line 205 of file GlobalStatistics.cc.
Referenced by BaseOverlay::finish(), BaseApp::finish(), SimMud::finishApp(), Scribe::finishApp(), KBRTestApp::finishApp(), DHTTestApp::finishApp(), DHT::finishApp(), Vast::finishOverlay(), QuonPR::finishOverlay(), QuonP::finishOverlay(), PubSubMMOG::finishOverlay(), PubSubLobby::finishOverlay(), oversim::Koorde::finishOverlay(), Kademlia::finishOverlay(), oversim::Chord::finishOverlay(), Broose::finishOverlay(), and BasePastry::finishOverlay().
00206 { 00207 return simTime() - ((creationTime > measureStartTime) 00208 ? creationTime : measureStartTime); 00209 }
| 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 nodesInitialized = nodesFinished = 0; 00038 00039 measuring = par("measureNetwInitPhase"); 00040 measureStartTime = 0; 00041 00042 currentDeliveryVector.setName("Current Delivery Ratio"); 00043 00044 // start periodic globalStatTimer 00045 globalStatTimerInterval = par("globalStatTimerInterval"); 00046 00047 if (globalStatTimerInterval > 0) { 00048 globalStatTimer = new cMessage("globalStatTimer"); 00049 scheduleAt(simTime() + globalStatTimerInterval, globalStatTimer); 00050 } 00051 00052 WATCH(measuring); 00053 WATCH(measureStartTime); 00054 WATCH(currentDeliveryVector); 00055 }
| void GlobalStatistics::handleMessage | ( | cMessage * | msg | ) | [protected, virtual] |
HandleMessage member function of module.
Definition at line 66 of file GlobalStatistics.cc.
00067 { 00068 if (msg == globalStatTimer) { 00069 // schedule next timer event 00070 scheduleAt(simTime() + globalStatTimerInterval, msg); 00071 00072 double ratio; 00073 00074 // quick hack for live display of the current KBR delivery ratio 00075 if (sentKBRTestAppMessages == 0) { 00076 ratio = 0; 00077 } else { 00078 ratio = (double)deliveredKBRTestAppMessages / 00079 (double)sentKBRTestAppMessages; 00080 } 00081 00082 if (ratio > 1) ratio = 1; 00083 00084 currentDeliveryVector.record(ratio); 00085 sentKBRTestAppMessages = 0; 00086 deliveredKBRTestAppMessages = 0; 00087 00088 return; 00089 } 00090 00091 error("GlobalStatistics::handleMessage(): Unknown message type!"); 00092 }
| void GlobalStatistics::finish | ( | ) | [protected, virtual] |
Finish member function of module.
Definition at line 94 of file GlobalStatistics.cc.
00095 { 00096 doFinish(); 00097 }
total number of messages sent by KBRTestApp
Definition at line 52 of file GlobalStatistics.h.
Referenced by handleMessage(), KBRTestApp::handleTimerEvent(), and initialize().
total number of messages delivered by KBRTestApp
Definition at line 53 of file GlobalStatistics.h.
Referenced by KBRTestApp::evaluateData(), handleMessage(), and initialize().
Definition at line 54 of file GlobalStatistics.h.
| cOutVector GlobalStatistics::currentDeliveryVector |
statistical output vector for current delivery ratio
Definition at line 55 of file GlobalStatistics.h.
Referenced by handleMessage(), and initialize().
nodes that have run initialize() and "registered" with GlobalStatistics
Definition at line 58 of file GlobalStatistics.h.
Referenced by doFinish(), initialize(), and BaseOverlay::initialize().
nodes that have run finished() and have "deregistered" with GlobalStatistics
Definition at line 59 of file GlobalStatistics.h.
Referenced by doFinish(), BaseOverlay::finish(), and initialize().
std::map<std::string, cStdDev*> GlobalStatistics::stdDevMap [protected] |
map to store and access the statistics data
Definition at line 103 of file GlobalStatistics.h.
Referenced by addStdDev(), doFinish(), and ~GlobalStatistics().
std::map<std::string, OutVector*> GlobalStatistics::outVectorMap [protected] |
map to store and access the output vectors
Definition at line 104 of file GlobalStatistics.h.
Referenced by doFinish(), recordOutVector(), and ~GlobalStatistics().
cMessage* GlobalStatistics::globalStatTimer [protected] |
timer for periodic statistic updates
Definition at line 105 of file GlobalStatistics.h.
Referenced by handleMessage(), and initialize().
double GlobalStatistics::globalStatTimerInterval [protected] |
interval length of periodic statistic timer
Definition at line 106 of file GlobalStatistics.h.
Referenced by handleMessage(), and initialize().
bool GlobalStatistics::measuring [protected] |
Definition at line 123 of file GlobalStatistics.h.
Referenced by addStdDev(), initialize(), isMeasuring(), recordOutVector(), and startMeasuring().
simtime_t GlobalStatistics::measureStartTime [protected] |
Definition at line 124 of file GlobalStatistics.h.
Referenced by calcMeasuredLifetime(), getMeasureStartTime(), initialize(), and startMeasuring().
1.5.5