#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 char *name, double value) |
add a value to a cStdDev | |
void | recordOutVector (const char *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) |
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 | |
map< const char *, cStdDev * > | cStdDevMap |
map to store and access the statistics data | |
map< const char *, OutVector * > | cOutVectorMap |
map to store and access the output vectors | |
cMessage * | globalStatTimer |
timer for periodic statistic updates | |
double | globalStatTimerInterval |
interval length of periodic statistic timer | |
bool | measureNetwInitPhase |
bool | measuring |
simtime_t | measureStartTime |
Classes | |
class | OutVector |
< struct for cOutVectors and cummulated values More... |
GlobalStatistics::~GlobalStatistics | ( | ) |
Destructor.
00163 { 00164 // clean up maps 00165 for (map<const char*, cStdDev*>::iterator iter = cStdDevMap.begin(); iter != cStdDevMap.end(); iter++) 00166 { 00167 delete iter->second; 00168 } 00169 00170 for (map<const char*, OutVector*>::iterator iter = cOutVectorMap.begin(); iter != cOutVectorMap.end(); iter++) 00171 { 00172 delete iter->second; 00173 } 00174 00175 cStdDevMap.clear(); 00176 cOutVectorMap.clear(); 00177 }
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.
00094 { 00095 if (nodesInitialized != nodesFinished) return; 00096 00097 recordScalar("GlobalStatistics: Simulation Time", simTime()); 00098 00099 bool outputMinMax = par("outputMinMax"); 00100 bool outputVariance = par("outputVariance"); 00101 00102 // record stats from other modules 00103 for (map<const char*, cStdDev*>::iterator iter = cStdDevMap.begin(); iter != cStdDevMap.end(); iter++) 00104 { 00105 std::string n = iter->first; 00106 cStatistic *stat = iter->second; 00107 00108 recordScalar((n + ".mean").c_str(), stat->mean()); 00109 00110 if (outputVariance) 00111 recordScalar((n + ".stddev").c_str(), stat->stddev()); 00112 00113 if (outputMinMax) 00114 { 00115 recordScalar((n + ".min").c_str(), stat->min()); 00116 recordScalar((n + ".max").c_str(), stat->max()); 00117 } 00118 } 00119 00120 for (map<const char*, OutVector*>::iterator iter = cOutVectorMap.begin(); iter != cOutVectorMap.end(); iter++) 00121 { 00122 std::string n = iter->first; 00123 OutVector* ov = iter->second; 00124 00125 double mean = ov->count > 0 ? ov->value / ov->count : 0; 00126 00127 recordScalar(("Vector: " + n + ".mean").c_str(), mean); 00128 } 00129 00130 }
void GlobalStatistics::addStdDev | ( | const char * | name, | |
double | value | |||
) |
add a value to a cStdDev
00133 { 00134 if (cStdDevMap.find(name) == cStdDevMap.end()) 00135 { 00136 Enter_Method_Silent(); 00137 cStdDevMap.insert(pair<const char*, cStdDev*>(name, new cStdDev(name))); 00138 } 00139 00140 *cStdDevMap[name] += value; 00141 }
void GlobalStatistics::recordOutVector | ( | const char * | name, | |
double | value | |||
) |
record a value to a global cOutVector defined by name
00144 { 00145 if (cOutVectorMap.find(name) == cOutVectorMap.end()) 00146 { 00147 Enter_Method_Silent(); 00148 cOutVectorMap.insert(pair<const char*, OutVector*>(name, new OutVector(name))); 00149 } 00150 OutVector* ov = cOutVectorMap[name]; 00151 ov->vector->record(value); 00152 ov->value += value; 00153 ov->count++; 00154 }
void GlobalStatistics::startMeasuring | ( | ) |
00054 { 00055 if(!measuring) { 00056 measuring = true; 00057 measureStartTime = simTime(); 00058 } 00059 }
bool GlobalStatistics::isMeasuring | ( | ) | [inline] |
simtime_t GlobalStatistics::getMeasureStartTime | ( | ) | [inline] |
simtime_t GlobalStatistics::calcMeasuredLifetime | ( | simtime_t | creationTime | ) |
00157 { 00158 return simTime() - ((creationTime > measureStartTime) 00159 ? creationTime : measureStartTime); 00160 }
void GlobalStatistics::initialize | ( | ) | [protected, virtual] |
Init member function of module.
00031 { 00032 sentKBRTestAppMessages = 0; 00033 deliveredKBRTestAppMessages = 0; 00034 00035 nodesInitialized = nodesFinished = 0; 00036 00037 measureNetwInitPhase = par("measureNetwInitPhase"); 00038 measuring = measureNetwInitPhase; 00039 measureStartTime = 0; 00040 00041 currentDeliveryVector.setName("Current Delivery Ratio"); 00042 00043 // start periodic globalStatTimer 00044 globalStatTimerInterval = par("globalStatTimerInterval"); 00045 globalStatTimer = new cMessage("globalStatTimer"); 00046 scheduleAt(simulation.simTime() + globalStatTimerInterval, globalStatTimer); 00047 00048 WATCH(measuring); 00049 WATCH(measureStartTime); 00050 WATCH(currentDeliveryVector); 00051 }
void GlobalStatistics::handleMessage | ( | cMessage * | msg | ) | [protected, virtual] |
HandleMessage member function of module.
00063 { 00064 if (msg == globalStatTimer) { 00065 // schedule next timer event 00066 scheduleAt(simulation.simTime() + globalStatTimerInterval, msg); 00067 00068 double ratio; 00069 00070 if (sentKBRTestAppMessages == 0) { 00071 ratio = 0; 00072 } else { 00073 ratio = (double)deliveredKBRTestAppMessages / 00074 (double)sentKBRTestAppMessages; 00075 } 00076 if (ratio > 1) ratio = 1; 00077 00078 currentDeliveryVector.record(ratio); 00079 sentKBRTestAppMessages = 0; 00080 deliveredKBRTestAppMessages = 0; 00081 00082 return; 00083 } 00084 00085 error("GlobalStatistics::handleMessage(): Unknown message type!"); 00086 }
void GlobalStatistics::finish | ( | ) | [protected, virtual] |
total number of messages sent by KBRTestApp
total number of messages delivered by KBRTestApp
cOutVector GlobalStatistics::currentDeliveryVector |
statistical output vector for current delivery ratio
nodes that have run initialize() and "registered" with GlobalStatistics
nodes that have run finished() and have "deregistered" with GlobalStatistics
map<const char*, cStdDev*> GlobalStatistics::cStdDevMap [protected] |
map to store and access the statistics data
map<const char*, OutVector*> GlobalStatistics::cOutVectorMap [protected] |
map to store and access the output vectors
cMessage* GlobalStatistics::globalStatTimer [protected] |
timer for periodic statistic updates
double GlobalStatistics::globalStatTimerInterval [protected] |
interval length of periodic statistic timer
bool GlobalStatistics::measureNetwInitPhase [protected] |
bool GlobalStatistics::measuring [protected] |
simtime_t GlobalStatistics::measureStartTime [protected] |