1 30 package org.apache.commons.httpclient.contrib.benchmark; 31 32 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 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 (); 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 getServerName() { 109 return this.serverName; 110 } 111 112 public void setServerName(final String serverName) { 113 this.serverName = serverName; 114 } 115 116 } 117 | Popular Tags |