KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > httpclient > contrib > benchmark > Stats


1 /*
2  * $HeadURL: https://svn.apache.org/repos/asf/jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/benchmark/Stats.java $
3  * $Revision: 480424 $
4  * $Date: 2006-11-29 05:56:49 +0000 (Wed, 29 Nov 2006) $
5  *
6  * ====================================================================
7  *
8  * Licensed to the Apache Software Foundation (ASF) under one or more
9  * contributor license agreements. See the NOTICE file distributed with
10  * this work for additional information regarding copyright ownership.
11  * The ASF licenses this file to You under the Apache License, Version 2.0
12  * (the "License"); you may not use this file except in compliance with
13  * the License. You may obtain a copy of the License at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  * ====================================================================
23  *
24  * This software consists of voluntary contributions made by many
25  * individuals on behalf of the Apache Software Foundation. For more
26  * information on the Apache Software Foundation, please see
27  * <http://www.apache.org/>.
28  *
29  */

30 package org.apache.commons.httpclient.contrib.benchmark;
31
32 /**
33  * <p>Benchmark statistics</p>
34  *
35  * @author <a HREF="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
36  *
37  * @version $Revision: 480424 $
38  */

39 public class Stats {
40
41     private long startTime = -1;
42     private long finishTime = -1;
43     private int successCount = 0;
44     private int failureCount = 0;
45     private String JavaDoc serverName = null;
46     private long total = 0;
47     private long contentLength = -1;
48     
49     public Stats() {
50         super();
51     }
52
53     public void start() {
54         this.startTime = System.currentTimeMillis();
55     }
56
57     public void finish() {
58         this.finishTime = System.currentTimeMillis();
59     }
60
61     public long getFinishTime() {
62         return this.finishTime;
63     }
64
65     public long getStartTime() {
66         return this.startTime;
67     }
68
69     public long getDuration() {
70         if (this.startTime < 0 || this.finishTime < 0) {
71             throw new IllegalStateException JavaDoc();
72         }
73         return this.finishTime - this.startTime;
74     }
75     
76     public void incSuccessCount() {
77         this.successCount++;
78     }
79     
80     public void incFailureCount() {
81         this.failureCount++;
82     }
83
84     public int getFailureCount() {
85         return this.failureCount;
86     }
87
88     public int getSuccessCount() {
89         return this.successCount;
90     }
91
92     public long getTotal() {
93         return this.total;
94     }
95     
96     public void incTotal(int n) {
97         this.total += n;
98     }
99     
100     public long getContentLength() {
101         return this.contentLength;
102     }
103
104     public void setContentLength(long contentLength) {
105         this.contentLength = contentLength;
106     }
107
108     public String JavaDoc getServerName() {
109         return this.serverName;
110     }
111
112     public void setServerName(final String JavaDoc serverName) {
113         this.serverName = serverName;
114     }
115     
116 }
117
Popular Tags