KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ch > ethz > prose > jikesrvm > JikesRVMPerformanceTest


1 package ch.ethz.prose.jikesrvm;
2
3 import ch.ethz.inf.util.junit.PerformanceTest;
4
5 import com.ibm.JikesRVM.VM_Time;
6
7 /**
8  * Chronometers are adapted to use the CPU cycle counter from Jikes RVM.
9  *
10  * @author Johann Gyger
11  */

12 public class JikesRVMPerformanceTest extends PerformanceTest {
13
14   public static final double MILLIS_TO_NANOS = 1000000.0;
15
16   protected static long startCycle;
17
18   protected static long endCycle;
19
20   public JikesRVMPerformanceTest(String JavaDoc name) {
21     super(name);
22   }
23
24   public static void startChronometer() {
25     startCycle = VM_Time.cycles();
26   }
27
28   public static void stopChronometer() {
29     endCycle = VM_Time.cycles();
30   }
31
32   /**
33    * @return duration in nanoseconds (!)
34    */

35   public long readChronometer() {
36     return (long) (VM_Time.cyclesToMillis(endCycle - startCycle) * MILLIS_TO_NANOS);
37   }
38
39 }
40
Popular Tags