#include <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.
00208 { 00209 // deallocate vectors 00210 for (map<std::string, cStdDev*>::iterator iter = stdDevMap.begin(); 00211 iter != stdDevMap.end(); iter++) { 00212 delete iter->second; 00213 } 00214 stdDevMap.clear(); 00215 00216 for (map<std::string, OutVector*>::iterator iter = outVectorMap.begin(); 00217 iter != outVectorMap.end(); iter++) { 00218 delete iter->second; 00219 } 00220 outVectorMap.clear(); 00221 }
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.
Referenced by finish(), and BaseOverlay::finish().
00096 { 00097 if (nodesInitialized != nodesFinished) return; 00098 00099 recordScalar("GlobalStatistics: Simulation Time", simTime()); 00100 00101 bool outputMinMax = par("outputMinMax"); 00102 bool outputStdDev = par("outputStdDev"); 00103 00104 // record stats from other modules 00105 for (map<const std::string, cStdDev*>::iterator iter = stdDevMap.begin(); 00106 iter != stdDevMap.end(); iter++) { 00107 00108 const std::string& n = iter->first; 00109 const cStatistic& stat = *(iter->second); 00110 00111 recordScalar((n + ".mean").c_str(), stat.mean()); 00112 00113 if (outputStdDev) 00114 recordScalar((n + ".stddev").c_str(), stat.stddev()); 00115 00116 if (outputMinMax) { 00117 recordScalar((n + ".min").c_str(), stat.min()); 00118 recordScalar((n + ".max").c_str(), stat.max()); 00119 } 00120 } 00121 00122 for (map<const std::string, OutVector*>::iterator iter = outVectorMap.begin(); 00123 iter != outVectorMap.end(); iter++) { 00124 00125 const OutVector& ov = *(iter->second); 00126 00127 double mean = ov.count > 0 ? ov.value / ov.count : 0; 00128 00129 recordScalar(("Vector: " + iter->first + ".mean").c_str(), mean); 00130 } 00131 }
void GlobalStatistics::addStdDev | ( | const std::string & | name, | |
double | value | |||
) |
add a value to a cStdDev
Referenced by SimpleUDP::finish(), BaseOverlay::finish(), BaseApp::finish(), SimMud::finishApp(), Scribe::finishApp(), KBRTestApp::finishApp(), GIASearchApp::finishApp(), DHTTestApp::finishApp(), DHT::finishApp(), Vast::finishOverlay(), PubSubMMOG::finishOverlay(), PubSubLobby::finishOverlay(), Koorde::finishOverlay(), Kademlia::finishOverlay(), Gia::finishOverlay(), Chord::finishOverlay(), Broose::finishOverlay(), BasePastry::finishOverlay(), DHTTestApp::handleGetResponse(), PubSubMMOG::handleMoveListMessage(), Vast::handleNodeMove(), SimMud::handleOtherPlayerMove(), and DHTTestApp::handlePutResponse().
00134 { 00135 if (!measuring) { 00136 return; 00137 } 00138 00139 std::map<std::string, cStdDev*>::iterator sdPos = stdDevMap.find(name); 00140 cStdDev* sd = NULL; 00141 00142 if (sdPos == stdDevMap.end()) { 00143 Enter_Method_Silent(); 00144 sd = new cStdDev(name.c_str()); 00145 stdDevMap.insert(pair<std::string, cStdDev*>(name, sd)); 00146 } else { 00147 sd = sdPos->second; 00148 } 00149 00150 *sd += value; 00151 }
void GlobalStatistics::recordOutVector | ( | const std::string & | name, | |
double | value, | |||
int | avg = -1 | |||
) |
record a value to a global cOutVector defined by name
Referenced by ParetoChurn::createNode(), LifetimeChurn::createNode(), ParetoChurn::deleteNode(), LifetimeChurn::deleteNode(), KBRTestApp::evaluateData(), GlobalDhtTestMap::handleMessage(), BootstrapOracle::handleMessage(), and ParetoChurn::initializeChurn().
00155 { 00156 if (!measuring) { 00157 return; 00158 } 00159 00160 std::map<std::string, OutVector*>::iterator ovPos = 00161 outVectorMap.find(name); 00162 OutVector* ov = NULL; 00163 00164 if (ovPos == outVectorMap.end()) { 00165 Enter_Method_Silent(); 00166 ov = new OutVector(name); 00167 outVectorMap.insert(pair<std::string, OutVector*>(name, ov)); 00168 } else { 00169 ov = ovPos->second; 00170 } 00171 00172 ov->vector.record(value); 00173 ov->value += value; 00174 ov->count++; 00175 00176 // avg vector 00177 if (avg != -1) { 00178 std::string name_avg = name + "_avg"; 00179 std::map<std::string, OutVector*>::iterator ovPos_avg = 00180 outVectorMap.find(name_avg); 00181 OutVector* ov_avg = NULL; 00182 00183 if (ovPos_avg == outVectorMap.end()) { 00184 Enter_Method_Silent(); 00185 ov_avg = new OutVector(name_avg); 00186 outVectorMap.insert(pair<std::string, OutVector*>(name_avg, ov_avg)); 00187 } else { 00188 ov_avg = ovPos_avg->second; 00189 } 00190 int div = ((ov_avg->count >= avg) ? (avg - 1) : ov_avg->count); 00191 if (div <= 0) div = 1; 00192 00193 double newValue = (ov_avg->avg * div + value) / (div + 1); 00194 ov_avg->vector.record(newValue); 00195 ov_avg->avg = newValue; 00196 ov_avg->value += newValue; 00197 ov_avg->count++; 00198 } 00199 }
void GlobalStatistics::startMeasuring | ( | ) |
Referenced by UnderlayConfigurator::handleMessage().
00055 { 00056 if (!measuring) { 00057 measuring = true; 00058 measureStartTime = simTime(); 00059 } 00060 }
bool GlobalStatistics::isMeasuring | ( | ) | [inline] |
Referenced by KBRTestApp::handleTimerEvent(), DHTTestApp::handleTimerEvent(), DHTTestApp::handleTraceMessage(), and IterativeLookup::sendRpc().
00085 { return measuring; };
simtime_t GlobalStatistics::getMeasureStartTime | ( | ) | [inline] |
simtime_t GlobalStatistics::calcMeasuredLifetime | ( | simtime_t | creationTime | ) |
Referenced by BaseOverlay::finish(), BaseApp::finish(), SimMud::finishApp(), Scribe::finishApp(), KBRTestApp::finishApp(), DHTTestApp::finishApp(), DHT::finishApp(), Vast::finishOverlay(), PubSubMMOG::finishOverlay(), PubSubLobby::finishOverlay(), Koorde::finishOverlay(), Kademlia::finishOverlay(), Chord::finishOverlay(), Broose::finishOverlay(), and BasePastry::finishOverlay().
00202 { 00203 return simTime() - ((creationTime > measureStartTime) 00204 ? creationTime : measureStartTime); 00205 }
void GlobalStatistics::initialize | ( | ) | [protected, virtual] |
Init member function of module.
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 globalStatTimer = new cMessage("globalStatTimer"); 00047 scheduleAt(simulation.simTime() + globalStatTimerInterval, globalStatTimer); 00048 00049 WATCH(measuring); 00050 WATCH(measureStartTime); 00051 WATCH(currentDeliveryVector); 00052 }
void GlobalStatistics::handleMessage | ( | cMessage * | msg | ) | [protected, virtual] |
HandleMessage member function of module.
00064 { 00065 if (msg == globalStatTimer) { 00066 // schedule next timer event 00067 scheduleAt(simulation.simTime() + globalStatTimerInterval, msg); 00068 00069 double ratio; 00070 00071 if (sentKBRTestAppMessages == 0) { 00072 ratio = 0; 00073 } else { 00074 ratio = (double)deliveredKBRTestAppMessages / 00075 (double)sentKBRTestAppMessages; 00076 } 00077 00078 if (ratio > 1) ratio = 1; 00079 00080 currentDeliveryVector.record(ratio); 00081 sentKBRTestAppMessages = 0; 00082 deliveredKBRTestAppMessages = 0; 00083 00084 return; 00085 } 00086 00087 error("GlobalStatistics::handleMessage(): Unknown message type!"); 00088 }
void GlobalStatistics::finish | ( | ) | [protected, virtual] |
total number of messages sent by KBRTestApp
Referenced by handleMessage(), KBRTestApp::handleTimerEvent(), and initialize().
total number of messages delivered by KBRTestApp
Referenced by KBRTestApp::evaluateData(), handleMessage(), and initialize().
cOutVector GlobalStatistics::currentDeliveryVector |
statistical output vector for current delivery ratio
Referenced by handleMessage(), and initialize().
nodes that have run initialize() and "registered" with GlobalStatistics
Referenced by doFinish(), initialize(), and BaseOverlay::initialize().
nodes that have run finished() and have "deregistered" with GlobalStatistics
Referenced by doFinish(), BaseOverlay::finish(), and initialize().
std::map<std::string, cStdDev*> GlobalStatistics::stdDevMap [protected] |
map to store and access the statistics data
Referenced by addStdDev(), doFinish(), and ~GlobalStatistics().
std::map<std::string, OutVector*> GlobalStatistics::outVectorMap [protected] |
map to store and access the output vectors
Referenced by doFinish(), recordOutVector(), and ~GlobalStatistics().
cMessage* GlobalStatistics::globalStatTimer [protected] |
double GlobalStatistics::globalStatTimerInterval [protected] |
bool GlobalStatistics::measuring [protected] |
Referenced by addStdDev(), initialize(), isMeasuring(), recordOutVector(), and startMeasuring().
simtime_t GlobalStatistics::measureStartTime [protected] |
Referenced by calcMeasuredLifetime(), getMeasureStartTime(), initialize(), and startMeasuring().