1 #include "sink.h"
2
3
4 Define_Module( Sink );
5
6 void Sink::activity()
7 {
8
9 sInfo.clearResult();
10 totalCount = 0;
11
12
13 int sampleCount = par("sample_count");
14
15
16 cOutVector srt("system response time", 1);
17
18
19 for(int i = 0; i<sampleCount; i++)
20 {
21
22 cMessage *msg = receive();
23
24 simtime_t msrt = simTime() - msg->timestamp();
25 sInfo.collect(msrt);
26 srt.record(msrt);
27
28 delete msg;
29 }
30 endSimulation();
31 }
32
33 void Sink::finish()
34 {
35 ev << "Total jobs processed: " << totalCount + sInfo.samples() << endl;
36 ev << "Number of jobs used for statistics: " << sInfo.samples() << endl;
37 ev << "Avg system response time: " << sInfo.mean() << endl;
38 ev << "Standard deviation: " << sInfo.stddev() << endl;
39 ev << "Max system response time: " << sInfo.max() << endl;
40 ev << "Min system response time: " << sInfo.min() << endl;
41
42 ev << endl;
43 }
44
45 void Sink::reset()
46 {
47
48 totalCount += sInfo.samples();
49 sInfo.clearResult();
50 }
51