Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1696 | - | 1 | package dongfang.mkt.frames; |
2 | |||
3 | public class ProfilerResponseFrame extends ResponseFrame { |
||
4 | |||
5 | private final static int NUM_ENTRIES = 16; |
||
6 | |||
7 | private int[] activities= new int[NUM_ENTRIES]; |
||
8 | private int totalHits; |
||
9 | |||
10 | public ProfilerResponseFrame(int address) { |
||
11 | super(address); |
||
12 | } |
||
13 | |||
14 | public int[] getActivities() { |
||
15 | return activities; |
||
16 | } |
||
17 | |||
18 | public void setActivity(int index, int value) { |
||
19 | this.activities[index ]= value; |
||
20 | } |
||
21 | |||
22 | @Override |
||
23 | public boolean isResponseTo(RequestFrame r) { |
||
24 | return r instanceof ProfilerRequestFrame; |
||
25 | } |
||
26 | |||
27 | public int getTotalHits() { |
||
28 | return totalHits; |
||
29 | } |
||
30 | |||
31 | public void setTotalHits(int totalHits) { |
||
32 | this.totalHits = totalHits; |
||
33 | } |
||
34 | |||
35 | public double asFraction(int activity) { |
||
36 | return (double)activities[activity] / (double)totalHits; |
||
37 | } |
||
38 | |||
39 | public String toString() { |
||
40 | StringBuilder result = new StringBuilder(); |
||
41 | result.append(getClass().getSimpleName()+"\r"); |
||
42 | result.append("activities\r"); |
||
43 | for (int i=0; i<activities.length; i++) { |
||
44 | result.append(i); |
||
45 | result.append(':'); |
||
46 | result.append(activities[i]); |
||
47 | result.append('\r'); |
||
48 | } |
||
49 | return result.toString(); |
||
50 | } |
||
51 | } |