001: /*
002: * $HeadURL: https://svn.apache.org/repos/asf/jakarta/httpcomponents/oac.hc3x/tags/HTTPCLIENT_3_1/src/contrib/org/apache/commons/httpclient/contrib/benchmark/Stats.java $
003: * $Revision: 480424 $
004: * $Date: 2006-11-29 06:56:49 +0100 (Wed, 29 Nov 2006) $
005: *
006: * ====================================================================
007: *
008: * Licensed to the Apache Software Foundation (ASF) under one or more
009: * contributor license agreements. See the NOTICE file distributed with
010: * this work for additional information regarding copyright ownership.
011: * The ASF licenses this file to You under the Apache License, Version 2.0
012: * (the "License"); you may not use this file except in compliance with
013: * the License. You may obtain a copy of the License at
014: *
015: * http://www.apache.org/licenses/LICENSE-2.0
016: *
017: * Unless required by applicable law or agreed to in writing, software
018: * distributed under the License is distributed on an "AS IS" BASIS,
019: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
020: * See the License for the specific language governing permissions and
021: * limitations under the License.
022: * ====================================================================
023: *
024: * This software consists of voluntary contributions made by many
025: * individuals on behalf of the Apache Software Foundation. For more
026: * information on the Apache Software Foundation, please see
027: * <http://www.apache.org/>.
028: *
029: */
030: package org.apache.commons.httpclient.contrib.benchmark;
031:
032: /**
033: * <p>Benchmark statistics</p>
034: *
035: * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
036: *
037: * @version $Revision: 480424 $
038: */
039: public class Stats {
040:
041: private long startTime = -1;
042: private long finishTime = -1;
043: private int successCount = 0;
044: private int failureCount = 0;
045: private String serverName = null;
046: private long total = 0;
047: private long contentLength = -1;
048:
049: public Stats() {
050: super ();
051: }
052:
053: public void start() {
054: this .startTime = System.currentTimeMillis();
055: }
056:
057: public void finish() {
058: this .finishTime = System.currentTimeMillis();
059: }
060:
061: public long getFinishTime() {
062: return this .finishTime;
063: }
064:
065: public long getStartTime() {
066: return this .startTime;
067: }
068:
069: public long getDuration() {
070: if (this .startTime < 0 || this .finishTime < 0) {
071: throw new IllegalStateException();
072: }
073: return this .finishTime - this .startTime;
074: }
075:
076: public void incSuccessCount() {
077: this .successCount++;
078: }
079:
080: public void incFailureCount() {
081: this .failureCount++;
082: }
083:
084: public int getFailureCount() {
085: return this .failureCount;
086: }
087:
088: public int getSuccessCount() {
089: return this .successCount;
090: }
091:
092: public long getTotal() {
093: return this .total;
094: }
095:
096: public void incTotal(int n) {
097: this .total += n;
098: }
099:
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 getServerName() {
109: return this .serverName;
110: }
111:
112: public void setServerName(final String serverName) {
113: this.serverName = serverName;
114: }
115:
116: }
|