These are the Delaunay Refinement files with the generics removed. It was a bit tedio...
[IRC.git] / Robust / src / Benchmarks / oooJava / DelaunayRefinement / Time.java
1 import java.lang.management.GarbageCollectorMXBean;
2 import java.lang.management.ManagementFactory;
3 import java.util.*;
4
5 public final class Time {
6         
7     public Time() {
8     }
9         
10     public static long getNewTimeId() {
11         return getNewTimeId(5);
12     }
13         
14     public static long getNewTimeId(int collections) {
15         for(int i = 0; i < collections; i++)
16             System.gc();
17                 
18         counter++;
19         times.put(Long.valueOf(counter), new Pair(Long.valueOf(milliTime()), Long.valueOf(milliGcTime())));
20         return counter;
21     }
22         
23     public static long elapsedTime(long id) {
24         Pair startTimes = (Pair)times.get(Long.valueOf(id));
25         return elapsedTime(((Long)startTimes.getFirst()).longValue(), ((Long)startTimes.getSecond()).longValue());
26     }
27         
28     private static long elapsedTime(long startTime, long startGcTime) {
29         return (milliTime() - startTime - milliGcTime()) + startGcTime;
30     }
31         
32     public static long elapsedTime(long id, boolean includeGc) {
33         Pair elapsedGcTimes = elapsedAndGcTime(id);
34         long elapsedTime = ((Long)elapsedGcTimes.getFirst()).longValue();
35         long gcTime = ((Long)elapsedGcTimes.getSecond()).longValue();
36         return includeGc ? elapsedTime : elapsedTime - gcTime;
37     }
38         
39     public static Pair elapsedAndGcTime(long id) {
40         long milliTime = milliTime();
41         long milliGcTime = milliGcTime();
42         Pair startTimes = (Pair)times.get(Long.valueOf(id));
43         long startTime = ((Long)startTimes.getFirst()).longValue();
44         long startGcTime = ((Long)startTimes.getSecond()).longValue();
45         return new Pair(Long.valueOf(milliTime - startTime), Long.valueOf(milliGcTime - startGcTime));
46     }
47         
48     private static long milliTime() {
49         return System.nanoTime() / 0xf4240L;
50     }
51         
52     public static long milliGcTime() {
53         long result = 0L;
54         for(Iterator iterator = garbageCollectorMXBeans.iterator(); iterator.hasNext();) {
55             GarbageCollectorMXBean garbageCollectorMXBean = (GarbageCollectorMXBean)iterator.next();
56             result += Math.max(0L, garbageCollectorMXBean.getCollectionTime());
57         }
58                 
59         return result;
60     }
61         
62     private static final List garbageCollectorMXBeans = ManagementFactory.getGarbageCollectorMXBeans();
63     private static long counter = 0x0L;
64     private static Map times = new HashMap();
65         
66 }