//------------------------------------------------------------- // file: sink1.cc // (part of Fifo1 - an OMNeT++ demo simulation) //------------------------------------------------------------- #include "sink1.h" #include using namespace std; Define_Module( FF2Sink ); void FF2Sink::activity() { qstats.setName("queuing time stats"); cOutVector qtime("queueing time vector"); for(;;) { cMessage *msg = receive(); double d = simTime()-msg->timestamp(); // ev << "Received " << msg->name() << ", queueing time: " << d << "sec" << endl; qtime.record( d ); qstats.collect( d ); bool end = msg->hasPar("last_msg"); delete msg; if (end) endSimulation(); } } void FF2Sink::finish() { ofstream of(parentModule()->submodule("fifo")->par("hist_file"), ios::app); of << "*** Module: " << fullPath() << "***" << endl; of << "Total jobs processed: " << qstats.samples() << endl; of << "Avg queueing time: " << qstats.mean() << endl; of << "Max queueing time: " << qstats.max() << endl; of << "Standard deviation: " << qstats.stddev() << endl; ev << endl; ev << "Stack allocated: " << stackSize() << " bytes"; ev << " (includes " << ev.extraStackForEnvir() << " bytes for environment)" << endl; ev << "Stack actually used: " << stackUsage() << " bytes" << endl; }