Module to record global statistics. More...
#include <GlobalStatistics.h>
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 | recordHistogram (const std::string &name, double value) |
Add a value to the histogram plot, or create a new histogram if one hasn't yet been created with name. | |
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 scalars | |
std::map< std::string, cHistogram * > | histogramMap |
map to store and access histograms | |
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 |
Module to record global statistics.
Definition at line 50 of file GlobalStatistics.h.
GlobalStatistics::~GlobalStatistics | ( | ) |
Destructor.
Definition at line 213 of file GlobalStatistics.cc.
{ // deallocate vectors for (map<std::string, cStdDev*>::iterator it = stdDevMap.begin(); it != stdDevMap.end(); it++) { delete it->second; } stdDevMap.clear(); for (map<std::string, OutVector*>::iterator it = outVectorMap.begin(); it != outVectorMap.end(); it++) { delete it->second; } outVectorMap.clear(); for (map<std::string, cHistogram*>::iterator iter = histogramMap.begin(); iter != histogramMap.end(); iter++) { delete iter->second; } histogramMap.clear(); }
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
name | a string to identify the container (should be "Module: Scalar Name") | |
value | the value to add |
Definition at line 144 of file GlobalStatistics.cc.
Referenced by Nps::coordsReqRpcResponse(), SimpleUDP::finish(), SimpleTCP::finish(), MessageObserver::finish(), CryptoModule::finish(), BaseOverlay::finish(), BaseApp::finish(), TCPExampleApp::finishApp(), SimpleGameClient::finishApp(), SimMud::finishApp(), Scribe::finishApp(), NeighborCache::finishApp(), MyApplication::finishApp(), KBRTestApp::finishApp(), GIASearchApp::finishApp(), DHTTestApp::finishApp(), DHT::finishApp(), CBRDHT::finishApp(), Vast::finishOverlay(), Quon::finishOverlay(), PubSubMMOG::finishOverlay(), PubSubLobby::finishOverlay(), NTree::finishOverlay(), oversim::Nice::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(), NTree::handleMove(), PubSubMMOG::handleMoveListMessage(), NTree::handleMoveMessage(), Vast::handleNodeMove(), Quon::handleNodeMove(), SimMud::handleOtherPlayerMove(), and DHTTestApp::handlePutResponse().
{ if (!measuring) { return; } std::map<std::string, cStdDev*>::iterator sdPos = stdDevMap.find(name); cStdDev* sd = NULL; if (sdPos == stdDevMap.end()) { Enter_Method_Silent(); sd = new cStdDev(name.c_str()); stdDevMap.insert(pair<std::string, cStdDev*>(name, sd)); } else { sd = sdPos->second; } sd->collect(value); }
simtime_t GlobalStatistics::calcMeasuredLifetime | ( | simtime_t | creationTime | ) |
Definition at line 207 of file GlobalStatistics.cc.
Referenced by MessageObserver::finish(), CryptoModule::finish(), BaseOverlay::finish(), BaseApp::finish(), SimMud::finishApp(), Scribe::finishApp(), KBRTestApp::finishApp(), DHTTestApp::finishApp(), DHT::finishApp(), CBRDHT::finishApp(), PubSubMMOG::finishOverlay(), PubSubLobby::finishOverlay(), NTree::finishOverlay(), oversim::Nice::finishOverlay(), oversim::Koorde::finishOverlay(), Kademlia::finishOverlay(), oversim::Chord::finishOverlay(), Broose::finishOverlay(), and BasePastry::finishOverlay().
{ return simTime() - ((creationTime > measureStartTime) ? creationTime : measureStartTime); }
void GlobalStatistics::finalizeStatistics | ( | ) |
Definition at line 105 of file GlobalStatistics.cc.
{ recordScalar("GlobalStatistics: Simulation Time", simTime()); bool outputMinMax = par("outputMinMax"); bool outputStdDev = par("outputStdDev"); // record stats from other modules for (map<std::string, cStdDev*>::iterator iter = stdDevMap.begin(); iter != stdDevMap.end(); iter++) { const std::string& n = iter->first; const cStatistic& stat = *(iter->second); recordScalar((n + ".mean").c_str(), stat.getMean()); if (outputStdDev) recordScalar((n + ".stddev").c_str(), stat.getStddev()); if (outputMinMax) { recordScalar((n + ".min").c_str(), stat.getMin()); recordScalar((n + ".max").c_str(), stat.getMax()); } } for (map<std::string, cHistogram*>::iterator iter = histogramMap.begin(); iter != histogramMap.end(); iter++) { const std::string& n = iter->first; recordStatistic(n.c_str(), iter->second); } for (map<std::string, OutVector*>::iterator iter = outVectorMap.begin(); iter != outVectorMap.end(); iter++) { const OutVector& ov = *(iter->second); double mean = ov.count > 0 ? ov.value / ov.count : 0; recordScalar(("Vector: " + iter->first + ".mean").c_str(), mean); } }
void GlobalStatistics::finish | ( | ) | [protected, virtual] |
Finish member function of module.
Definition at line 94 of file GlobalStatistics.cc.
{ // Here, the FinisherModule is created which will get destroyed at last. // This way, all other modules have sent their statistical data to the // GobalStatisticModule before GlobalStatistics::finalizeStatistics() // is called by FinisherModule::finish() cModuleType* moduleType = cModuleType::get("oversim.common.FinisherModule"); moduleType->create("finisherModule", getParentModule()->getParentModule()); }
simtime_t GlobalStatistics::getMeasureStartTime | ( | ) | [inline] |
Definition at line 91 of file GlobalStatistics.h.
{ return measureStartTime; };
void GlobalStatistics::handleMessage | ( | cMessage * | msg | ) | [protected, virtual] |
HandleMessage member function of module.
Definition at line 66 of file GlobalStatistics.cc.
{ if (msg == globalStatTimer) { // schedule next timer event scheduleAt(simTime() + globalStatTimerInterval, msg); double ratio; // quick hack for live display of the current KBR delivery ratio if (sentKBRTestAppMessages == 0) { ratio = 0; } else { ratio = (double)deliveredKBRTestAppMessages / (double)sentKBRTestAppMessages; } if (ratio > 1) ratio = 1; currentDeliveryVector.record(ratio); sentKBRTestAppMessages = 0; deliveredKBRTestAppMessages = 0; return; } error("GlobalStatistics::handleMessage(): Unknown message type!"); }
void GlobalStatistics::initialize | ( | ) | [protected, virtual] |
Init member function of module.
Definition at line 34 of file GlobalStatistics.cc.
{ sentKBRTestAppMessages = 0; deliveredKBRTestAppMessages = 0; measuring = par("measureNetwInitPhase"); measureStartTime = 0; currentDeliveryVector.setName("Current Delivery Ratio"); // start periodic globalStatTimer globalStatTimerInterval = par("globalStatTimerInterval"); if (globalStatTimerInterval > 0) { globalStatTimer = new cMessage("globalStatTimer"); scheduleAt(simTime() + globalStatTimerInterval, globalStatTimer); } WATCH(measuring); WATCH(measureStartTime); WATCH(currentDeliveryVector); }
bool GlobalStatistics::isMeasuring | ( | ) | [inline] |
Definition at line 90 of file GlobalStatistics.h.
Referenced by NeighborCache::calcRttError(), KBRTestApp::handleTimerEvent(), DHTTestApp::handleTimerEvent(), and DHTTestApp::handleTraceMessage().
{ return measuring; };
void GlobalStatistics::recordHistogram | ( | const std::string & | name, | |
double | value | |||
) |
Add a value to the histogram plot, or create a new histogram if one hasn't yet been created with name.
Definition at line 164 of file GlobalStatistics.cc.
{ if (!measuring) { return; } std::map<std::string, cHistogram*>::iterator hPos = histogramMap.find(name); cHistogram* h = NULL; if (hPos == histogramMap.end()) { Enter_Method_Silent(); h = new cHistogram(name.c_str()); histogramMap.insert(pair<std::string, cHistogram*>(name, h)); } else { h = hPos->second; } h->collect(value); }
void GlobalStatistics::recordOutVector | ( | const std::string & | name, | |
double | value | |||
) |
Record a value to a global cOutVector defined by name.
name | a string to identify the vector (should be "Module: Scalar Name") | |
value | the value to add |
Definition at line 184 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().
{ if (!measuring) { return; } std::map<std::string, OutVector*>::iterator ovPos = outVectorMap.find(name); OutVector* ov = NULL; if (ovPos == outVectorMap.end()) { Enter_Method_Silent(); ov = new OutVector(name); outVectorMap.insert(pair<std::string, OutVector*>(name, ov)); } else { ov = ovPos->second; } ov->vector.record(value); ov->value += value; ov->count++; }
void GlobalStatistics::startMeasuring | ( | ) |
Definition at line 57 of file GlobalStatistics.cc.
Referenced by UnderlayConfigurator::handleMessage().
{ if (!measuring) { measuring = true; measureStartTime = simTime(); } }
cOutVector GlobalStatistics::currentDeliveryVector |
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 113 of file GlobalStatistics.h.
Referenced by handleMessage(), and initialize().
double GlobalStatistics::globalStatTimerInterval [protected] |
interval length of periodic statistic timer
Definition at line 114 of file GlobalStatistics.h.
Referenced by handleMessage(), and initialize().
std::map<std::string, cHistogram*> GlobalStatistics::histogramMap [protected] |
map to store and access histograms
Definition at line 111 of file GlobalStatistics.h.
Referenced by finalizeStatistics(), recordHistogram(), and ~GlobalStatistics().
simtime_t GlobalStatistics::measureStartTime [protected] |
Definition at line 132 of file GlobalStatistics.h.
Referenced by calcMeasuredLifetime(), getMeasureStartTime(), initialize(), and startMeasuring().
bool GlobalStatistics::measuring [protected] |
Definition at line 131 of file GlobalStatistics.h.
Referenced by addStdDev(), initialize(), isMeasuring(), recordHistogram(), recordOutVector(), and startMeasuring().
const double GlobalStatistics::MIN_MEASURED = 0.1 [static] |
minimum useful measured lifetime in seconds
Definition at line 53 of file GlobalStatistics.h.
Referenced by MessageObserver::finish(), CryptoModule::finish(), BaseOverlay::finish(), BaseApp::finish(), SimpleGameClient::finishApp(), SimMud::finishApp(), Scribe::finishApp(), KBRTestApp::finishApp(), DHTTestApp::finishApp(), DHT::finishApp(), PubSubMMOG::finishOverlay(), PubSubLobby::finishOverlay(), NTree::finishOverlay(), oversim::Nice::finishOverlay(), oversim::Koorde::finishOverlay(), Kademlia::finishOverlay(), oversim::Chord::finishOverlay(), Broose::finishOverlay(), and BasePastry::finishOverlay().
std::map<std::string, OutVector*> GlobalStatistics::outVectorMap [protected] |
map to store and access the output vectors
Definition at line 112 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 scalars
Definition at line 110 of file GlobalStatistics.h.
Referenced by addStdDev(), finalizeStatistics(), and ~GlobalStatistics().
Definition at line 57 of file GlobalStatistics.h.