1 /**************************************************************************
3 * Java Grande Forum Benchmark Suite - Thread Version 1.0 *
7 * Java Grande Benchmarking Project *
11 * Edinburgh Parallel Computing Centre *
13 * email: epcc-javagrande@epcc.ed.ac.uk *
16 * This version copyright (c) The University of Edinburgh, 1999. *
17 * All rights reserved. *
19 **************************************************************************/
20 public class JGFInstrumentor{
22 protected HashMap timers;
23 protected HashMap data;
25 public JGFInstrumentor() {
26 timers = new HashMap();
30 public static void addTimer (String name, HashMap timers){
32 if (timers.containsKey(name)) {
33 System.printString("JGFInstrumentor.addTimer: warning - timer " + name +
37 timers.put(name, new JGFTimer(name));
41 public static void addTimer (String name, String opname, HashMap timers){
43 if (timers.containsKey(name)) {
44 System.printString("JGFInstrumentor.addTimer: warning - timer " + name +
48 timers.put(name, new JGFTimer(name,opname));
53 public static void addTimer (String name, String opname, int size, HashMap timers){
55 if (timers.containsKey(name)) {
56 System.printString("JGFInstrumentor.addTimer: warning - timer " + name +
60 timers.put(name, new JGFTimer(name,opname,size));
65 public static void startTimer(String name, HashMap timers){
66 if (timers.containsKey(name)) {
67 ((JGFTimer) timers.get(name)).start();
70 System.printString("JGFInstrumentor.startTimer: failed - timer " + name +
76 public static void stopTimer(String name, HashMap timers){
77 if (timers.containsKey(name)) {
78 ((JGFTimer) timers.get(name)).stop();
81 System.printString("JGFInstrumentor.stopTimer: failed - timer " + name +
86 public static void addOpsToTimer(String name, double count, HashMap timers){
87 if (timers.containsKey(name)) {
88 ((JGFTimer) timers.get(name)).addops(count);
91 System.printString("JGFInstrumentor.addOpsToTimer: failed - timer " + name +
96 public static void addTimeToTimer(String name, double added_time, HashMap timers){
97 if (timers.containsKey(name)) {
98 ((JGFTimer) timers.get(name)).addtime(added_time);
101 System.printString("JGFInstrumentor.addTimeToTimer: failed - timer " + name +
102 " does not exist\n");
109 public static double readTimer(String name, HashMap timers){
111 if (timers.containsKey(name)) {
112 time = ((JGFTimer) timers.get(name)).time;
115 System.printString("JGFInstrumentor.readTimer: failed - timer " + name +
116 " does not exist\n");
122 public static void resetTimer(String name, HashMap timers){
123 if (timers.containsKey(name)) {
124 ((JGFTimer) timers.get(name)).reset();
127 System.printString("JGFInstrumentor.resetTimer: failed - timer " + name +
128 " does not exist\n");
132 public static void printTimer(String name, HashMap timers){
133 if (timers.containsKey(name)) {
134 ((JGFTimer) timers.get(name)).print();
137 System.printString("JGFInstrumentor.printTimer: failed - timer " + name +
138 " does not exist\n");
142 public static void printperfTimer(String name, HashMap timers){
143 if (timers.containsKey(name)) {
144 ((JGFTimer) timers.get(name)).printperf();
147 System.printString("JGFInstrumentor.printTimer: failed - timer " + name +
148 " does not exist\n");
152 public static void storeData(String name, Object obj, HashMap data){
156 public static void retrieveData(String name, Object obj, HashMap data){
157 obj = data.get(name);
160 public static void printHeader(int section, int size,int nthreads) {
165 base = "Java Grande Forum Thread Benchmark Suite - Version 1.0 - Section ";
171 else if (section == 2)
174 header = base + "2 - Size A";
176 header = base + "2 - Size B";
178 header = base + "2 - Size C";
180 else if (section == 3)
183 header = base + "3 - Size A";
185 header = base + "3 - Size B";
188 System.printString(header + "\n");
191 System.printString("Executing on " + nthreads + " thread\n");
194 System.printString("Executing on " + nthreads + " threads\n");
197 System.printString(" \n");