home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Extras / OSpace / jgl.exe / jgl_2_0 / COM / objectspace / jgl / Benchmark.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-03-12  |  1.6 KB  |  60 lines

  1. package COM.objectspace.jgl;
  2.  
  3. import java.util.Date;
  4.  
  5. public class Benchmark {
  6.    long begin;
  7.    long total;
  8.    String title;
  9.    int count;
  10.    int cycle;
  11.  
  12.    public Benchmark(String var1, int var2) {
  13.       this.cycle = 100;
  14.       this.title = var1;
  15.       this.cycle = var2;
  16.    }
  17.  
  18.    public Benchmark(String var1) {
  19.       this(var1, 0);
  20.    }
  21.  
  22.    public Benchmark() {
  23.       this("<untitled>", 0);
  24.    }
  25.  
  26.    public void start() {
  27.       this.begin = (new Date()).getTime();
  28.    }
  29.  
  30.    public void stop() {
  31.       this.total += (new Date()).getTime() - this.begin;
  32.       if (this.count > 0 && this.cycle > 0 && this.count % this.cycle == 0) {
  33.          System.out.println(this);
  34.       }
  35.  
  36.       ++this.count;
  37.    }
  38.  
  39.    public long getMilliseconds() {
  40.       return this.total;
  41.    }
  42.  
  43.    public String getTitle() {
  44.       return this.title;
  45.    }
  46.  
  47.    public int getCount() {
  48.       return this.count;
  49.    }
  50.  
  51.    public String toString() {
  52.       return "Benchmark( " + this.getTitle() + " x " + this.count + ": " + this.total + " ms )";
  53.    }
  54.  
  55.    public void compareTo(Benchmark var1) {
  56.       float var2 = (float)this.total / (float)var1.total;
  57.       System.out.println("ratio of " + this.getTitle() + " to " + var1.getTitle() + " is " + var2);
  58.    }
  59. }
  60.