View Javadoc

1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.saxbenchmark;
17  
18  import java.math.BigDecimal;
19  
20  /***
21   * @author JMcCrindle
22   */
23  public class BenchmarkResult {
24      
25      private Benchmark benchmark = null;
26      private long parseTime = 0L;
27      private long parseMemory = 0L;
28      private Throwable exception = null;
29      
30      public BenchmarkResult() {
31          
32      }
33      
34      /***
35       * @param benchmark
36       * @param parseTime
37       * @param parseMemory
38       * @param exception
39       */
40      public BenchmarkResult(Benchmark benchmark, long parseTime,
41              long parseMemory, Throwable exception) {
42          super();
43          this.benchmark = benchmark;
44          this.parseTime = parseTime;
45          this.parseMemory = parseMemory;
46          this.exception = exception;
47      }
48      
49      public Benchmark getBenchmark() {
50          return benchmark;
51      }
52      public void setBenchmark(Benchmark benchmark) {
53          this.benchmark = benchmark;
54      }
55      public long getParseTime() {
56          return parseTime;
57      }
58      public BigDecimal getParseTimeAverage() {
59          return new BigDecimal((double) parseTime / (double) benchmark.getCount()).setScale(3, BigDecimal.ROUND_HALF_EVEN); 
60      }
61      public void setParseTime(long parseTime) {
62          this.parseTime = parseTime;
63      }
64      public Throwable getException() {
65          return exception;
66      }
67      public void setException(Throwable exception) {
68          this.exception = exception;
69      }
70      public long getParseMemory() {
71          return parseMemory;
72      }
73      public void setParseMemory(long parseMemory) {
74          this.parseMemory = parseMemory;
75      }
76  }