1 5 package org.exoplatform.test.web; 6 12 public class WebUnitMonitor { 13 private int counter_ ; 14 private int errorCounter_ ; 15 private int xhtmlMalformedCounter_ ; 16 private long sumExecutionTime_ ; 17 private long sumContentLength_ ; 18 19 public WebUnitMonitor() { 20 reset() ; 21 } 22 23 public void reset() { 24 counter_ = 0; 25 sumExecutionTime_ = 0 ; 26 sumContentLength_ = 0 ; 27 xhtmlMalformedCounter_ = 0; 28 errorCounter_ = 0 ; 29 } 30 31 public int getCounter() { return counter_ ; } 32 public int getErrorCounter() { return errorCounter_ ; } 33 public int getXhtmlMalformedCounter() { return xhtmlMalformedCounter_ ; } 34 35 public long getAvgExecutionTime() { 36 if(counter_ == 0) return 0 ; 37 return sumExecutionTime_/counter_ ; 38 } 39 40 public long getAvgContentLength() { 41 if(counter_ == 0) return 0 ; 42 return sumContentLength_/counter_ ; 43 } 44 45 public long getSumContentLength() { 46 return sumContentLength_ ; 47 } 48 49 synchronized public void log(long executionTime , int contentLength, boolean error, boolean malformed) { 50 sumExecutionTime_ += executionTime ; 51 sumContentLength_ += contentLength ; 52 counter_++ ; 53 if(error) errorCounter_++ ; 54 if(malformed) xhtmlMalformedCounter_++ ; 55 } 56 } 57 | Popular Tags |