1 package net.sourceforge.pmd.benchmark;
2
3
4 class BenchmarkResult implements Comparable<BenchmarkResult> {
5
6 public final Benchmark type;
7 public final String name;
8 private long time;
9 private long count;
10
11 public BenchmarkResult(Benchmark type, String name) {
12 this.type = type;
13 this.name = name;
14 }
15 public BenchmarkResult(Benchmark type, long time, long count) {
16 this(type, type.name);
17 this.time = time;
18 this.count = count;
19 }
20
21 public long getTime() { return time; }
22 public long getCount() { return count; }
23
24 public void update(long time, long count) {
25 this.time += time;
26 this.count += count;
27 }
28
29 public int compareTo(BenchmarkResult benchmarkResult) {
30 int cmp = type.index - benchmarkResult.type.index;
31 if (cmp == 0) {
32 long delta = this.time - benchmarkResult.time;
33 cmp = delta > 0 ? 1 : (delta < 0 ? -1 : 0);
34 }
35 return cmp;
36 }
37 }