move heap size of output program into the benchmark-specific makefile
[IRC.git] / Robust / src / Benchmarks / oooJava / raytracer / JGFInstrumentor.java
1 //import String;
2 //import System;
3
4 //import java.util.Hashtable;
5
6 /**************************************************************************
7 *                                                                         *
8 *             Java Grande Forum Benchmark Suite - Version 2.0             *
9 *                                                                         *
10 *                            produced by                                  *
11 *                                                                         *
12 *                  Java Grande Benchmarking Project                       *
13 *                                                                         *
14 *                                at                                       *
15 *                                                                         *
16 *                Edinburgh Parallel Computing Centre                      *
17 *                                                                         * 
18 *                email: epcc-javagrande@epcc.ed.ac.uk                     *
19 *                                                                         *
20 *                                                                         *
21 *      This version copyright (c) The University of Edinburgh, 1999.      *
22 *                         All rights reserved.                            *
23 *                                                                         *
24 **************************************************************************/
25
26 public class JGFInstrumentor{
27
28         private  Hashtable timers;
29         private  Hashtable data;
30 //  private static Hashtable timers;
31 //  private static Hashtable data; 
32 //
33 //  static {
34 //    timers = new Hashtable();
35 //    data = new Hashtable(); 
36 //  }
37         
38         public JGFInstrumentor(){
39                 timers=new Hashtable();
40                 data=new Hashtable();
41         }
42
43   public  synchronized void addTimer (String name){
44
45     if (timers.containsKey(name)) {
46       System.out.println("JGFInstrumentor.addTimer: warning -  timer " + name + 
47                          " already exists");
48     }
49     else {
50         JGFTimer t=new JGFTimer(name);
51         timers.put(name,t);
52 //      timers.put(name, new JGFTimer(name));
53     }
54   }
55     
56   public  synchronized void addTimer (String name, String opname){
57
58     if (timers.containsKey(name)) {
59       System.out.println("JGFInstrumentor.addTimer: warning -  timer " + name + 
60                          " already exists");
61     }
62     else {
63         JGFTimer t=new JGFTimer(name,opname);
64         timers.put(name,t);
65 //      timers.put(name, new JGFTimer(name,opname));
66     }
67     
68   }
69
70   public  synchronized void addTimer (String name, String opname, int size){
71
72     if (timers.containsKey(name)) {
73       System.out.println("JGFInstrumentor.addTimer: warning -  timer " + name +
74                          " already exists");
75     }
76     else {
77         JGFTimer t=new JGFTimer(name,opname,size);
78         timers.put(name,t);
79 //      timers.put(name, new JGFTimer(name,opname,size));
80     }
81
82   }
83
84   public  synchronized void startTimer(String name){
85     if (timers.containsKey(name)) {
86       ((JGFTimer) timers.get(name)).start();
87     }
88     else {
89       System.out.println("JGFInstrumentor.startTimer: failed -  timer " + name + 
90                          " does not exist");
91     }
92
93   }
94
95   public  synchronized void stopTimer(String name){
96     if (timers.containsKey(name)) {
97       ((JGFTimer) timers.get(name)).stop();
98     }
99     else {
100       System.out.println("JGFInstrumentor.stopTimer: failed -  timer " + name + 
101                          " does not exist");
102     }
103   }
104
105   public  synchronized void addOpsToTimer(String name, double count){
106     if (timers.containsKey(name)) {
107       ((JGFTimer) timers.get(name)).addops(count);
108     }
109     else {
110       System.out.println("JGFInstrumentor.addOpsToTimer: failed -  timer " + name + 
111                          " does not exist");
112     }
113   }  
114
115   public  synchronized double readTimer(String name){
116     double time; 
117     if (timers.containsKey(name)) {
118       time = ((JGFTimer) timers.get(name)).time;
119     }
120     else {
121       System.out.println("JGFInstrumentor.readTimer: failed -  timer " + name + 
122                          " does not exist");
123        time = 0.0; 
124     }
125     return time; 
126   }  
127
128   public  synchronized void resetTimer(String name){
129     if (timers.containsKey(name)) {
130       ((JGFTimer) timers.get(name)).reset();
131     }
132     else {
133       System.out.println("JGFInstrumentor.resetTimer: failed -  timer " + name +
134                          " does not exist");
135     }
136   }
137   
138   public  synchronized void printTimer(String name){
139     if (timers.containsKey(name)) {
140         JGFTimer t=(JGFTimer) timers.get(name);
141         t.print();
142 //      ((JGFTimer) timers.get(name)).print();
143     }
144     else {
145       System.out.println("JGFInstrumentor.printTimer: failed -  timer " + name +
146                          " does not exist");
147     }
148   }
149   
150   public  synchronized void printperfTimer(String name){
151     if (timers.containsKey(name)) {
152       ((JGFTimer) timers.get(name)).printperf();
153     }
154     else {
155       System.out.println("JGFInstrumentor.printTimer: failed -  timer " + name +
156                          " does not exist");
157     }
158   }
159   
160 //  public static synchronized void storeData(String name, Object obj){
161 //     data.put(name,obj); 
162 //  }
163
164   public  synchronized void retrieveData(String name, Object obj){
165     obj = data.get(name); 
166   }
167
168   public  synchronized void printHeader(int section, int size) {
169
170     String header, base; 
171  
172     header = "";
173     base = "Java Grande Forum Benchmark Suite - Version 2.0 - Section "; 
174     
175     if(section==1){
176         header = base + "1";
177     }else if(section==2){
178         if(size==0){
179                 header = base + "2 - Size A";
180         }else if(size==1){
181                 header = base + "2 - Size B";
182         }else if(size==2){
183                 header = base + "2 - Size C";
184         }
185     }else if(section==3){
186         if(size==0){
187                 header = base + "3 - Size A";
188         }else if(size==1){
189                 header = base + "3 - Size B";
190         }
191     }
192   
193     System.out.println(header); 
194     System.out.println("");
195     
196     
197
198   } 
199
200 }