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 **************************************************************************/
22 public class JGFTimer {
27 public double opcount;
31 private long start_time;
34 public JGFTimer(String name, String opname){
41 public JGFTimer(String name, String opname, int size){
48 public JGFTimer(String name){
57 if (on) System.out.println("Warning timer " + " was already turned on");
59 start_time = System.currentTimeMillis();
64 time += (double) (System.currentTimeMillis()-start_time) / 1000.;
65 if (!on) System.out.println("Warning timer " + " wasn't turned on");
70 public void addops(double count){
74 public void addtime(double added_time){
86 return opcount / time;
89 public void longprint(){
90 System.out.println("Timer Calls Time(s) Performance("+opname+"/s)");
91 System.out.println(name + " " + calls + " " + time + " " + this.perf());
95 if (opname.equals("")) {
96 System.out.println(name + " " + time + " (s)");
100 System.out.println(name + ":SizeA" + "\t" + time + " (s) \t " + this.perf() + "\t" + " ("+opname+"/s)");
101 } else if (size == 1) {
102 System.out.println(name + ":SizeB" + "\t" + time + " (s) \t " + this.perf() + "\t" + " ("+opname+"/s)");
103 } else if (size == 2) {
104 System.out.println(name + ":SizeC" + "\t" + time + " (s) \t " + this.perf() + "\t" + " ("+opname+"/s)");
106 System.out.println(name + "\t" + time + " (s) \t " + this.perf() + "\t" + " ("+opname+"/s)");
112 public void printperf(){
117 // pad name to 40 characters
118 while ( name.length() < 40 ) name = name + " ";
120 System.out.println(name + "\t" + this.perf() + "\t"
121 + " ("+opname+"/s)");