KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > TestAdvice


1 package test;
2
3 import alt.jiapi.util.HotSpotAdvice;
4
5 public class DefaultAdvice extends HotSpotAdvice {
6     public void advice() {
7     // NOTE: For some reason, we get class verify error,
8
// If we store longs into local variables,
9
// when having overlapping hotspots.
10
// Casting into ints before storing into
11
// local variable acts as a workaround for this bug.
12
int l1 = (int)System.currentTimeMillis();
13     
14     doHotSpot();
15
16     int l2 = (int)System.currentTimeMillis();
17     System.out.println("It took " + (l2-l1) + " ms to invoke " +
18         getHotSpotName());
19
20
21     if (l1 < l2) {
22         System.out.println("l1<l2");
23     }
24     else {
25         System.out.println("l2<l1");
26     }
27     }
28 }
29
Popular Tags