KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > measurements > suites > TestClass4


1
2 package measurements.suites;
3
4
5 public class TestClass4 extends TestClass implements TestInterface
6 {
7
8     public static boolean scallDummyMethod = false;
9     public boolean callDummyMethod = false;
10     public void dummyMethod(boolean callRecursively)
11     {
12     if (callRecursively)
13         dummyMethod(callRecursively);
14     }
15     public static void sdummyMethod(boolean callRecursively)
16     {
17     if (callRecursively)
18         sdummyMethod(callRecursively);
19     }
20
21     // fields
22
static int staticInt;
23     static long staticLong;
24     static Object JavaDoc staticObj;
25
26     private static int privateStaticInt;
27     private static long privateStaticLong;
28     private static Object JavaDoc privateStaticObj;
29
30     public int instanceInt;
31     public long instanceLong;
32     public Object JavaDoc instanceObj;
33
34     private int privateInstanceInt;
35     private long privateInstanceLong;
36     private Object JavaDoc privateInstanceObj;
37
38
39
40
41     // methods // body avoids optimizations (leaf methods)
42
public void interfaceMethodShort() { if (callDummyMethod) dummyMethod(callDummyMethod);}
43     public void interfaceMethodLong(Object JavaDoc x, Object JavaDoc o) { if (callDummyMethod) dummyMethod(callDummyMethod);}
44     public void instanceMethodShort() { if (callDummyMethod) dummyMethod(callDummyMethod);}
45     public void instanceMethodLong(Object JavaDoc x, Object JavaDoc o) { if (callDummyMethod) dummyMethod(callDummyMethod);}
46     public static void staticMethodShort() { if (scallDummyMethod) sdummyMethod(scallDummyMethod);}
47     public static void staticMethodLong(Object JavaDoc x, Object JavaDoc o) { if (scallDummyMethod) sdummyMethod(scallDummyMethod);}
48     private static void privateStaticMethodShort() { if (scallDummyMethod) sdummyMethod(scallDummyMethod);}
49     private static void privateStaticMethodLong(Object JavaDoc x, Object JavaDoc o) { if (scallDummyMethod) sdummyMethod(scallDummyMethod);}
50     public synchronized void syncInstanceMethodShort() { if (callDummyMethod) dummyMethod(callDummyMethod);}
51     public synchronized void syncInstanceMethodLong(Object JavaDoc x, Object JavaDoc o) { if (callDummyMethod) dummyMethod(callDummyMethod);}
52     private void privateInstanceMethodShort() { if (callDummyMethod) dummyMethod(callDummyMethod);}
53     private void privateInstanceMethodLong(Object JavaDoc x, Object JavaDoc o) { if (callDummyMethod) dummyMethod(callDummyMethod);}
54
55     public void testPutField(int runs)
56     {
57
58     for (int i=0; i < runs; i++)
59         this.instanceInt = 1;
60     }
61
62     public void testGetField(int runs)
63     {
64
65     int localInt=0;
66     for (int i=0; i < runs; i++)
67         localInt=this.instanceInt;
68     }
69
70
71     public void testNonJPOperations()
72     {
73     int i = 1;
74     int ii = 1;
75     int localInt = 1;
76     long localLong = 1;
77     Object JavaDoc localObj = new Object JavaDoc();
78     int[] localArr = new int[10];
79     Object JavaDoc oo = new TestClass4();
80
81     byte b1 = 1;
82     byte b2 = 1;
83     short s1 = 1;
84     short s2 = 1;
85     int i1 = 1;
86     int i2 = 1;
87     long l1 = 1;
88     long l2 = 1;
89
90     final Object JavaDoc tcObject = new TestClass4();
91     final int[] aa = new int[10];
92
93     // loop tests
94
for (ii = 0; ii < TestFrequency.LOCALLOOP; ii++)
95         ;
96     for (ii = TestFrequency.LOCALLOOP; --ii >= 0; )
97         ;
98
99     // check casts
100
for(i=TestFrequency.CHECKCAST;--i >= 0;)
101         {
102         oo=(TestClass4)oo;
103         }
104
105     // local operation
106
for(i=TestFrequency.LOCALVAR;--i >= 0;)
107         {
108         localInt = localInt;
109         localLong = localLong;
110         localObj = localObj;
111         localArr[0] = localArr[0];
112         }
113
114     // local additions
115
for (i=TestFrequency.LOCALADD;--i >= 0;)
116         {
117         i1+=i2;
118         s1+=s2;
119         l1+=s2;
120         b1+=b2;
121         }
122
123     // one throw catch
124
//try
125
// {
126
// throw new Exception();
127
// }
128
//catch (Exception e)
129
// {}
130

131     }
132
133     public void testFieldOperations()
134     {
135     int i;
136     int localInt = 1;
137     long localLong = 1;
138     Object JavaDoc localObj = new Object JavaDoc();
139     TestClass4 obj = new TestClass4();
140
141     // static puts
142
for(i=TestFrequency.PUTSTATIC/6;--i >= 0;)
143         {
144         // this static set
145
staticInt = localInt;
146         staticObj = localObj;
147         staticLong = localLong;
148
149         // private sta
150
privateStaticInt = localInt;
151         privateStaticObj = localObj;
152         privateStaticLong = localLong;
153         }
154
155
156     // static puts
157
for(i=TestFrequency.GET_ARGSSTATIC/6;--i >= 0;)
158         {
159         // this static get
160
localInt = staticInt;
161         localObj = staticObj;
162         localLong = staticLong;
163
164         // private static get
165
localInt = privateStaticInt;
166         localObj = privateStaticObj;
167         localLong = privateStaticLong;
168         }
169
170
171     // instance sets
172
for(i=TestFrequency.PUTFIELD/9;--i >= 0;)
173         {
174         // this.x=localX
175
instanceInt = localInt;
176         instanceObj = localObj;
177         instanceLong = localLong;
178
179         // private this.x=localX
180
privateInstanceInt = localInt;
181         privateInstanceObj = localObj;
182         privateInstanceLong = localLong;
183
184         // obj.x = localX
185
obj.instanceInt = localInt;
186         obj.instanceLong = localLong;
187         obj.instanceObj = localObj;
188
189         }
190
191
192     // getfields
193
for(i=TestFrequency.GET_ARGSFIELD/9;--i >= 0;)
194         {
195         // this instance get
196
localInt = instanceInt;
197         localObj = instanceObj;
198         localLong = instanceLong;
199
200         // private instance get
201
localInt = privateInstanceInt;
202         localObj = privateInstanceObj;
203         localLong = privateInstanceLong;
204
205         // obj gets
206
localInt = obj.instanceInt;
207         localObj = obj.instanceObj;
208         localLong = obj.instanceLong;
209         }
210     }
211
212
213     public void testMethodOperations()
214     {
215     TestInterface localInterface = new TestClass4();
216     TestClass4 obj = new TestClass4();
217     int localInt = 1;
218     Object JavaDoc localObj = new Object JavaDoc();
219     int i;
220
221     // invokeinterface
222
for(i=TestFrequency.INVOKEINTERFACE/2;--i >= 0;)
223         {
224         localInterface.interfaceMethodShort();
225         localInterface.interfaceMethodLong(localObj,localObj);
226         }
227
228     for(i=TestFrequency.INVOKESPECIAL/2;--i >= 0;)
229         {
230         // private
231
privateInstanceMethodShort();
232         privateInstanceMethodLong(localObj,localObj);
233         }
234
235     // invoke virtual
236
for(i=TestFrequency.INVOKEVIRTUAL/6;--i >= 0;)
237         {
238         instanceMethodShort();
239         instanceMethodLong(localObj,localObj);
240
241         syncInstanceMethodShort();
242         syncInstanceMethodLong(localObj,localObj);
243
244         obj.instanceMethodShort();
245         obj.instanceMethodLong(localObj,localObj);
246         }
247
248     // invoke static
249
for(i=TestFrequency.INVOKESTATIC/4;--i >= 0;)
250         {
251         staticMethodShort();
252         staticMethodLong(localObj,localObj);
253
254         privateStaticMethodShort();
255         privateStaticMethodLong(localObj,localObj);
256         }
257
258     }
259
260   }
261
Popular Tags