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 **************************************************************************/
21 public class JGFInstrumentor{
23 protected HashMap timers;
24 protected HashMap data;
26 public JGFInstrumentor() {
27 timers = new HashMap();
31 public static void addTimer (String name, HashMap timers){
33 if (timers.containsKey(name)) {
34 System.out.println("JGFInstrumentor.addTimer: warning - timer " + name +
38 timers.put(name, new JGFTimer(name));
42 public static void addTimer (String name, String opname, HashMap timers){
44 if (timers.containsKey(name)) {
45 System.out.println("JGFInstrumentor.addTimer: warning - timer " + name +
49 timers.put(name, new JGFTimer(name,opname));
54 public static void addTimer (String name, String opname, int size, HashMap timers){
56 if (timers.containsKey(name)) {
57 System.out.println("JGFInstrumentor.addTimer: warning - timer " + name +
61 timers.put(name, new JGFTimer(name,opname,size));
66 public static void startTimer(String name, HashMap timers){
67 if (timers.containsKey(name)) {
68 ((JGFTimer) timers.get(name)).start();
71 System.out.println("JGFInstrumentor.startTimer: failed - timer " + name +
77 public static void stopTimer(String name, HashMap timers){
78 if (timers.containsKey(name)) {
79 ((JGFTimer) timers.get(name)).stop();
82 System.out.println("JGFInstrumentor.stopTimer: failed - timer " + name +
87 public static void addOpsToTimer(String name, double count, HashMap timers){
88 if (timers.containsKey(name)) {
89 ((JGFTimer) timers.get(name)).addops(count);
92 System.out.println("JGFInstrumentor.addOpsToTimer: failed - timer " + name +
97 public static void addTimeToTimer(String name, double added_time, HashMap timers){
98 if (timers.containsKey(name)) {
99 ((JGFTimer) timers.get(name)).addtime(added_time);
102 System.out.println("JGFInstrumentor.addTimeToTimer: failed - timer " + name +
110 public static double readTimer(String name, HashMap timers){
112 if (timers.containsKey(name)) {
113 time = ((JGFTimer) timers.get(name)).time;
116 System.out.println("JGFInstrumentor.readTimer: failed - timer " + name +
123 public static void resetTimer(String name, HashMap timers){
124 if (timers.containsKey(name)) {
125 ((JGFTimer) timers.get(name)).reset();
128 System.out.println("JGFInstrumentor.resetTimer: failed - timer " + name +
133 public static void printTimer(String name, HashMap timers){
134 if (timers.containsKey(name)) {
135 ((JGFTimer) timers.get(name)).print();
138 System.out.println("JGFInstrumentor.printTimer: failed - timer " + name +
143 public static void printperfTimer(String name, HashMap timers){
144 if (timers.containsKey(name)) {
145 ((JGFTimer) timers.get(name)).printperf();
148 System.out.println("JGFInstrumentor.printTimer: failed - timer " + name +
153 public static void storeData(String name, Object obj, HashMap data){
157 public static void retrieveData(String name, Object obj, HashMap data){
158 obj = data.get(name);
161 public static void printHeader(int section, int size,int nthreads) {
166 base = "Java Grande Forum Thread Benchmark Suite - Version 1.0 - Section ";
172 else if (section == 2)
175 header = base + "2 - Size A";
177 header = base + "2 - Size B";
179 header = base + "2 - Size C";
181 else if (section == 3)
184 header = base + "3 - Size A";
186 header = base + "3 - Size B";
189 System.out.println(header);
192 System.out.println("Executing on " + nthreads + " thread");
195 System.out.println("Executing on " + nthreads + " threads");
198 System.out.println("");