1 import java.util.*;
2
3 public class TimeRecord {
4
5 Vector list;
6
7 public int time;
8
9 int low, high;
10
11 public TimeRecord(int timeLow, int timeHigh) {
12
13 low = timeLow;
14 high = timeHigh;
15 list = new Vector();
16
17 // System.out.println("Build a TR: l = " + low + " h = " + high);
18
19 }
20
21 public boolean isIn(TimeEntry entry) {
22
23 if ((entry.time > high)||(entry.time < low)) {
24 return false;
25 }
26 return true;
27 }
28
29 public boolean put(TimeEntry entry) {
30
31 if (!this.isIn(entry)) return false;
32
33 list.addElement(entry);
34 return true;
35 }
36
37 public String report() {
38
39 TimeEntry e;
40
41 int count = 0, aLatency = 0, aSize = 0, size = 0, latency = 0,
42 aGood = 0, aBad = 0, aNet = 0, time = 0;
43
44 StringBuffer output = new StringBuffer(" " + low + " -> " + high + " : ");
45
46 while (list.size() > 0) {
47 e = (TimeEntry) list.elementAt(0);
48 list.removeElementAt(0);
49
50 aLatency += e.latency;
51 aSize += e.size;
52
53 count++;
54
55 switch(e.result) {
56 case 1 : aGood++; break;
57 case 2 : aBad++; break;
58 case 3 : aNet++; break;
59 default :
60 System.out.println("Software Detected Fault: TimeRecord : Unknown result - " + e.result);
61 }
62
63 } // end while
64
65 if (count > 0 ) {
66 size = aSize / count;
67 latency = aLatency / count;
68 } else {
69 size = 0;
70 latency = 0;
71 }
72
73 output.append("c=" + count + " l=" + latency + " s=" + size + " GBN="
74 + aGood + "," + aBad + "," + aNet + " \n");
75
76 return output.toString();
77
78 }
79 }
80
|