home *** CD-ROM | disk | FTP | other *** search
- package COM.objectspace.jgl;
-
- import java.util.Date;
-
- public class Benchmark {
- long begin;
- long total;
- String title;
- int count;
- int cycle;
-
- public Benchmark(String var1, int var2) {
- this.cycle = 100;
- this.title = var1;
- this.cycle = var2;
- }
-
- public Benchmark(String var1) {
- this(var1, 0);
- }
-
- public Benchmark() {
- this("<untitled>", 0);
- }
-
- public void start() {
- this.begin = (new Date()).getTime();
- }
-
- public void stop() {
- this.total += (new Date()).getTime() - this.begin;
- if (this.count > 0 && this.cycle > 0 && this.count % this.cycle == 0) {
- System.out.println(this);
- }
-
- ++this.count;
- }
-
- public long getMilliseconds() {
- return this.total;
- }
-
- public String getTitle() {
- return this.title;
- }
-
- public int getCount() {
- return this.count;
- }
-
- public String toString() {
- return "Benchmark( " + this.getTitle() + " x " + this.count + ": " + this.total + " ms )";
- }
-
- public void compareTo(Benchmark var1) {
- float var2 = (float)this.total / (float)var1.total;
- System.out.println("ratio of " + this.getTitle() + " to " + var1.getTitle() + " is " + var2);
- }
- }
-