1 5 package org.exoplatform.container.monitor; 6 13 public class RequestMonitorData { 14 private long minRange_ ; 15 private long maxRange_ ; 16 private int requestCounter_ ; 17 private long minExecutionTime_ ; 18 private long maxExecutionTime_ ; 19 private long sumExecutionTime_ = 0 ; 20 21 public RequestMonitorData(long minRange, long maxRange) { 22 requestCounter_ = 0 ; 23 minExecutionTime_ = 0 ; 24 maxExecutionTime_ = 0 ; 25 minRange_ = minRange ; 26 maxRange_ = maxRange ; 27 } 28 29 public long minRange() { return minRange_ ; } 30 public long maxRange() { return maxRange_ ; } 31 32 public int getRequestCounter() { return requestCounter_ ; } 33 34 public long minExecutionTime() { return minExecutionTime_ ; } 35 36 public long maxExecutionTime() { return maxExecutionTime_ ; } 37 38 public long averageExecutionTime() { 39 if(requestCounter_ <= 0) return 0 ; 40 return sumExecutionTime_/requestCounter_ ; 41 } 42 43 public long sumExecutionTime() { return sumExecutionTime_ ; } 44 45 public void logRequest(long startTime, long endTime) { 46 requestCounter_++ ; 47 if(requestCounter_ > 0) { 48 long executionTime = endTime - startTime ; 49 sumExecutionTime_ += executionTime; 50 if(executionTime < minExecutionTime_) minExecutionTime_ = executionTime ; 51 if(executionTime > maxExecutionTime_) maxExecutionTime_ = executionTime ; 52 } 53 } 54 55 public void logRequest(long executionTime) { 56 requestCounter_++ ; 57 if(requestCounter_ > 0) { 58 sumExecutionTime_ += executionTime; 59 if(executionTime < minExecutionTime_) minExecutionTime_ = executionTime ; 60 if(executionTime > maxExecutionTime_) maxExecutionTime_ = executionTime ; 61 } 62 } 63 } 64 | Popular Tags |