Source code: org/apache/http/contrib/benchmark/Stats.java
1 /*
2 * $HeadURL: https://svn.apache.org/repos/asf/jakarta/httpcomponents/httpcore/tags/4.0-alpha2/src/contrib/org/apache/http/contrib/benchmark/Stats.java $
3 * $Revision: 376458 $
4 * $Date: 2006-02-09 23:22:06 +0100 (Thu, 09 Feb 2006) $
5 *
6 * ====================================================================
7 *
8 * Copyright 1999-2006 The Apache Software Foundation
9 *
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 * ====================================================================
22 *
23 * This software consists of voluntary contributions made by many
24 * individuals on behalf of the Apache Software Foundation. For more
25 * information on the Apache Software Foundation, please see
26 * <http://www.apache.org/>.
27 *
28 */
29 package org.apache.http.contrib.benchmark;
30
31 /**
32 * <p>
33 * </p>
34 * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
35 *
36 * @version $Revision: 376458 $
37 *
38 * @since 4.0
39 */
40 public class Stats {
41
42 private long startTime = -1;
43 private long finishTime = -1;
44 private int successCount = 0;
45 private int failureCount = 0;
46 private String serverName = null;
47 private long total = 0;
48 private long contentLength = -1;
49
50 public Stats() {
51 super();
52 }
53
54 public void start() {
55 this.startTime = System.currentTimeMillis();
56 }
57
58 public void finish() {
59 this.finishTime = System.currentTimeMillis();
60 }
61
62 public long getFinishTime() {
63 return this.finishTime;
64 }
65
66 public long getStartTime() {
67 return this.startTime;
68 }
69
70 public long getDuration() {
71 if (this.startTime < 0 || this.finishTime < 0) {
72 throw new IllegalStateException();
73 }
74 return this.finishTime - this.startTime;
75 }
76
77 public void incSuccessCount() {
78 this.successCount++;
79 }
80
81 public void incFailureCount() {
82 this.failureCount++;
83 }
84
85 public int getFailureCount() {
86 return this.failureCount;
87 }
88
89 public int getSuccessCount() {
90 return this.successCount;
91 }
92
93 public long getTotal() {
94 return this.total;
95 }
96
97 public void incTotal(int n) {
98 this.total += n;
99 }
100
101 public long getContentLength() {
102 return this.contentLength;
103 }
104
105 public void setContentLength(long contentLength) {
106 this.contentLength = contentLength;
107 }
108
109 public String getServerName() {
110 return this.serverName;
111 }
112
113 public void setServerName(final String serverName) {
114 this.serverName = serverName;
115 }
116
117 }