1
2
3
4
5
6 #include "sink1.h"
7 #include <fstream>
8
9 using namespace std;
10
11 Define_Module( FF2Sink );
12
13 void FF2Sink::activity()
14 {
15 qstats.setName("queuing time stats");
16 cOutVector qtime("queueing time vector");
17 for(;;)
18 {
19 cMessage *msg = receive();
20 double d = simTime()-msg->timestamp();
21
22 qtime.record( d );
23 qstats.collect( d );
24 bool end = msg->hasPar("last_msg");
25 delete msg;
26 if (end) endSimulation();
27 }
28 }
29
30 void FF2Sink::finish()
31 {
32 ofstream of(parentModule()->submodule("fifo")->par("hist_file"), ios::app);
33
34 of << "*** Module: " << fullPath() << "***" << endl;
35 of << "Total jobs processed: " << qstats.samples() << endl;
36 of << "Avg queueing time: " << qstats.mean() << endl;
37 of << "Max queueing time: " << qstats.max() << endl;
38 of << "Standard deviation: " << qstats.stddev() << endl;
39
40 ev << endl;
41 ev << "Stack allocated: " << stackSize() << " bytes";
42 ev << " (includes " << ev.extraStackForEnvir() << " bytes for environment)" << endl;
43 ev << "Stack actually used: " << stackUsage() << " bytes" << endl;
44 }
45
46