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 JGFTimer {
26 public double opcount;
30 private long start_time;
33 public JGFTimer(String name, String opname){
40 public JGFTimer(String name, String opname, int size){
47 public JGFTimer(String name){
56 if (on) System.printString("Warning timer " + " was already turned on");
58 start_time = System.currentTimeMillis();
63 time += (double) (System.currentTimeMillis()-start_time) / 1000.;
64 if (!on) System.printString("Warning timer " + " wasn't turned on");
69 public void addops(double count){
73 public void addtime(double added_time){
85 return opcount / time;
88 public void longprint(){
89 System.printString("Timer Calls Time(s) Performance("+opname+"/s)");
90 System.printString(name + " " + calls + " " + (long)time + " " + (long)this.perf());
94 if (opname.equals("")) {
95 System.printString(name + " " + (long)time + " (s)");
99 System.printString(name + ":SizeA" + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)");
100 } else if (size == 1) {
101 System.printString(name + ":SizeB" + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)");
102 } else if (size == 2) {
103 System.printString(name + ":SizeC" + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)");
105 System.printString(name + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)");
111 public void printperf(){
116 // pad name to 40 characters
117 while ( name.length() < 40 ) name = name + " ";
119 System.printString(name + "\t" + (long)this.perf() + "\t"
120 + " ("+opname+"/s)");