001: package measurements.suites;
002:
003: public class TestClass2 extends TestClass implements TestInterface {
004:
005: public static boolean scallDummyMethod = false;
006: public boolean callDummyMethod = false;
007:
008: public void dummyMethod(boolean callRecursively) {
009: if (callRecursively)
010: dummyMethod(callRecursively);
011: }
012:
013: public static void sdummyMethod(boolean callRecursively) {
014: if (callRecursively)
015: sdummyMethod(callRecursively);
016: }
017:
018: // fields
019: static int staticInt;
020: static long staticLong;
021: static Object staticObj;
022:
023: private static int privateStaticInt;
024: private static long privateStaticLong;
025: private static Object privateStaticObj;
026:
027: public int instanceInt;
028: public long instanceLong;
029: public Object instanceObj;
030:
031: private int privateInstanceInt;
032: private long privateInstanceLong;
033: private Object privateInstanceObj;
034:
035: // methods // body avoids optimizations (leaf methods)
036: public void interfaceMethodShort() {
037: if (callDummyMethod)
038: dummyMethod(callDummyMethod);
039: }
040:
041: public void interfaceMethodLong(Object x, Object o) {
042: if (callDummyMethod)
043: dummyMethod(callDummyMethod);
044: }
045:
046: public void instanceMethodShort() {
047: if (callDummyMethod)
048: dummyMethod(callDummyMethod);
049: }
050:
051: public void instanceMethodLong(Object x, Object o) {
052: if (callDummyMethod)
053: dummyMethod(callDummyMethod);
054: }
055:
056: public static void staticMethodShort() {
057: if (scallDummyMethod)
058: sdummyMethod(scallDummyMethod);
059: }
060:
061: public static void staticMethodLong(Object x, Object o) {
062: if (scallDummyMethod)
063: sdummyMethod(scallDummyMethod);
064: }
065:
066: private static void privateStaticMethodShort() {
067: if (scallDummyMethod)
068: sdummyMethod(scallDummyMethod);
069: }
070:
071: private static void privateStaticMethodLong(Object x, Object o) {
072: if (scallDummyMethod)
073: sdummyMethod(scallDummyMethod);
074: }
075:
076: public synchronized void syncInstanceMethodShort() {
077: if (callDummyMethod)
078: dummyMethod(callDummyMethod);
079: }
080:
081: public synchronized void syncInstanceMethodLong(Object x, Object o) {
082: if (callDummyMethod)
083: dummyMethod(callDummyMethod);
084: }
085:
086: private void privateInstanceMethodShort() {
087: if (callDummyMethod)
088: dummyMethod(callDummyMethod);
089: }
090:
091: private void privateInstanceMethodLong(Object x, Object o) {
092: if (callDummyMethod)
093: dummyMethod(callDummyMethod);
094: }
095:
096: public void testPutField(int runs) {
097:
098: for (int i = 0; i < runs; i++)
099: this .instanceInt = 1;
100: }
101:
102: public void testGetField(int runs) {
103:
104: int localInt = 0;
105: for (int i = 0; i < runs; i++)
106: localInt = this .instanceInt;
107: }
108:
109: public void testNonJPOperations() {
110: int i = 1;
111: int ii = 1;
112: int localInt = 1;
113: long localLong = 1;
114: Object localObj = new Object();
115: int[] localArr = new int[10];
116: Object oo = new TestClass2();
117:
118: byte b1 = 1;
119: byte b2 = 1;
120: short s1 = 1;
121: short s2 = 1;
122: int i1 = 1;
123: int i2 = 1;
124: long l1 = 1;
125: long l2 = 1;
126:
127: final Object tcObject = new TestClass2();
128: final int[] aa = new int[10];
129:
130: // loop tests
131: for (ii = 0; ii < TestFrequency.LOCALLOOP; ii++)
132: ;
133: for (ii = TestFrequency.LOCALLOOP; --ii >= 0;)
134: ;
135:
136: // check casts
137: for (i = TestFrequency.CHECKCAST; --i >= 0;) {
138: oo = (TestClass2) oo;
139: }
140:
141: // local operation
142: for (i = TestFrequency.LOCALVAR; --i >= 0;) {
143: localInt = localInt;
144: localLong = localLong;
145: localObj = localObj;
146: localArr[0] = localArr[0];
147: }
148:
149: // local additions
150: for (i = TestFrequency.LOCALADD; --i >= 0;) {
151: i1 += i2;
152: s1 += s2;
153: l1 += s2;
154: b1 += b2;
155: }
156:
157: // one throw catch
158: //try
159: // {
160: // throw new Exception();
161: // }
162: //catch (Exception e)
163: // {}
164:
165: }
166:
167: public void testFieldOperations() {
168: int i;
169: int localInt = 1;
170: long localLong = 1;
171: Object localObj = new Object();
172: TestClass2 obj = new TestClass2();
173:
174: // static puts
175: for (i = TestFrequency.PUTSTATIC / 6; --i >= 0;) {
176: // this static set
177: staticInt = localInt;
178: staticObj = localObj;
179: staticLong = localLong;
180:
181: // private sta
182: privateStaticInt = localInt;
183: privateStaticObj = localObj;
184: privateStaticLong = localLong;
185: }
186:
187: // static puts
188: for (i = TestFrequency.GET_ARGSSTATIC / 6; --i >= 0;) {
189: // this static get
190: localInt = staticInt;
191: localObj = staticObj;
192: localLong = staticLong;
193:
194: // private static get
195: localInt = privateStaticInt;
196: localObj = privateStaticObj;
197: localLong = privateStaticLong;
198: }
199:
200: // instance sets
201: for (i = TestFrequency.PUTFIELD / 9; --i >= 0;) {
202: // this.x=localX
203: instanceInt = localInt;
204: instanceObj = localObj;
205: instanceLong = localLong;
206:
207: // private this.x=localX
208: privateInstanceInt = localInt;
209: privateInstanceObj = localObj;
210: privateInstanceLong = localLong;
211:
212: // obj.x = localX
213: obj.instanceInt = localInt;
214: obj.instanceLong = localLong;
215: obj.instanceObj = localObj;
216:
217: }
218:
219: // getfields
220: for (i = TestFrequency.GET_ARGSFIELD / 9; --i >= 0;) {
221: // this instance get
222: localInt = instanceInt;
223: localObj = instanceObj;
224: localLong = instanceLong;
225:
226: // private instance get
227: localInt = privateInstanceInt;
228: localObj = privateInstanceObj;
229: localLong = privateInstanceLong;
230:
231: // obj gets
232: localInt = obj.instanceInt;
233: localObj = obj.instanceObj;
234: localLong = obj.instanceLong;
235: }
236: }
237:
238: public void testMethodOperations() {
239: TestInterface localInterface = new TestClass2();
240: TestClass2 obj = new TestClass2();
241: int localInt = 1;
242: Object localObj = new Object();
243: int i;
244:
245: // invokeinterface
246: for (i = TestFrequency.INVOKEINTERFACE / 2; --i >= 0;) {
247: localInterface.interfaceMethodShort();
248: localInterface.interfaceMethodLong(localObj, localObj);
249: }
250:
251: for (i = TestFrequency.INVOKESPECIAL / 2; --i >= 0;) {
252: // private
253: privateInstanceMethodShort();
254: privateInstanceMethodLong(localObj, localObj);
255: }
256:
257: // invoke virtual
258: for (i = TestFrequency.INVOKEVIRTUAL / 6; --i >= 0;) {
259: instanceMethodShort();
260: instanceMethodLong(localObj, localObj);
261:
262: syncInstanceMethodShort();
263: syncInstanceMethodLong(localObj, localObj);
264:
265: obj.instanceMethodShort();
266: obj.instanceMethodLong(localObj, localObj);
267: }
268:
269: // invoke static
270: for (i = TestFrequency.INVOKESTATIC / 4; --i >= 0;) {
271: staticMethodShort();
272: staticMethodLong(localObj, localObj);
273:
274: privateStaticMethodShort();
275: privateStaticMethodLong(localObj, localObj);
276: }
277:
278: }
279:
280: }
|