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 /**************************************************************************
21 * Ported for DSTM Benchmark *
22 **************************************************************************/
27 public class JGFTimer {
32 public double opcount;
36 private long start_time;
39 public JGFTimer(String name, String opname){
46 public JGFTimer(String name, String opname, int size){
53 public JGFTimer(String name){
62 if (on) System.printString("Warning timer " + name + " was already turned on");
64 start_time = System.currentTimeMillis();
69 time += (double) (System.currentTimeMillis()-start_time) / 1000.;
70 if (!on) System.printString("Warning timer " + name + " wasn't turned on");
75 public void addops(double count){
79 public void addtime(double added_time){
91 return opcount / time;
94 public void longprint(){
95 System.printString("Timer Calls Time(s) Performance("+opname+"/s)");
96 //System.printString(name + " " + calls + " " + time + " " + this.perf());
100 if (opname.equals(""))
102 System.printString(name + " " + (long)time + " (s)");
107 System.printString(name + ":SizeA" + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)");
108 } else if (size == 1) {
109 System.printString(name + ":SizeB" + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)");
110 } else if (size == 2) {
111 System.printString(name + ":SizeC" + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)");
113 System.printString(name + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)");
118 public void printperf(){
123 // pad name to 40 characters
124 while ( name.length() < 40 ) name = name + " ";
126 System.printString(name + "\t" + (long)this.perf() + "\t"
127 + " ("+opname+"/s)");