Coverage report

  %line %branch
net.sf.infrared.web.util.SqlStatistics
0% 
0% 

 1  
 /*
 2  
  *
 3  
  * Copyright 2005 Tavant Technologies and Contributors
 4  
  * 
 5  
  * Licensed under the Apache License, Version 2.0 (the "License")
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  *     http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  *
 17  
  *
 18  
  *
 19  
  * Original Author:  prashant.nair (Tavant Technologies)
 20  
  * Contributor(s):   -;
 21  
  *
 22  
  */
 23  
 package net.sf.infrared.web.util;
 24  
 
 25  
 import net.sf.infrared.base.model.AggregateExecutionTime;
 26  
 
 27  0
 public class SqlStatistics {
 28  
 
 29  0
     private String sql = null;
 30  
     private long noOfExecutes;
 31  
     private long noOfPrepares;
 32  
     private long maxExecuteTime;
 33  
     private long maxPrepareTime;
 34  0
     private long minExecuteTime = Long.MAX_VALUE;
 35  0
     private long minPrepareTime = Long.MAX_VALUE;
 36  
     private long lastExecuteTime;
 37  
     private long lastPrepareTime;
 38  
     private long firstExecuteTime;
 39  
     private long firstPrepareTime;
 40  
     private long totalExecuteTime;
 41  
     private long totalPrepareTime;
 42  0
     private long timeOfFirstPrepare = Long.MAX_VALUE;
 43  
     private long timeOfLastPrepare;
 44  0
     private long timeOfFirstExecute = Long.MAX_VALUE;
 45  
     private long timeOfLastExecute;
 46  
     
 47  
     public double getAvgExecuteTime() {
 48  0
         if (this.noOfExecutes == 0) {
 49  0
             return 0;
 50  
         }
 51  
         else {
 52  0
             return ((double) this.totalExecuteTime / class="keyword">this.noOfExecutes);
 53  
         }
 54  
     }    
 55  
     public double getAvgTotalTime() {
 56  0
         return  getAvgExecuteTime() + getAvgPrepareTime();
 57  
     }    
 58  
     public void setTotalExecuteTime(long totalExecuteTime) {
 59  0
         this.totalExecuteTime = totalExecuteTime;
 60  0
     }
 61  
     public double getAvgPrepareTime() {
 62  0
         if (this.noOfPrepares == 0) {
 63  0
             return 0;
 64  
         }
 65  
         else {
 66  0
             return ((double) this.totalPrepareTime / class="keyword">this.noOfPrepares);
 67  
         }
 68  
     }
 69  
     public void setTotalPrepareTime(long totalPrepareTime) {
 70  0
         this.totalPrepareTime = totalPrepareTime;
 71  0
     }
 72  
     public long getFirstExecuteTime() {
 73  0
         return firstExecuteTime;
 74  
     }
 75  
     public void setFirstExecuteTime(long firstExecuteTime) {
 76  0
         this.firstExecuteTime = firstExecuteTime;
 77  0
     }
 78  
     public long getFirstPrepareTime() {
 79  0
         return firstPrepareTime;
 80  
     }
 81  
     public void setFirstPrepareTime(long firstPrepareTime) {
 82  0
         this.firstPrepareTime = firstPrepareTime;
 83  0
     }
 84  
     public long getLastExecuteTime() {
 85  0
         return lastExecuteTime;
 86  
     }
 87  
     public void setLastExecuteTime(long lastExecuteTime) {
 88  0
         this.lastExecuteTime = lastExecuteTime;
 89  0
     }
 90  
     public long getLastPrepareTime() {
 91  0
         return lastPrepareTime;
 92  
     }
 93  
     public void setLastPrepareTime(long lastPrepareTime) {
 94  0
         this.lastPrepareTime = lastPrepareTime;
 95  0
     }
 96  
     public long getMaxExecuteTime() {
 97  0
         return maxExecuteTime;
 98  
     }
 99  
     public void setMaxExecuteTime(long maxExecuteTime) {
 100  0
         this.maxExecuteTime = maxExecuteTime;
 101  0
     }
 102  
     public long getMaxPrepareTime() {
 103  0
         return maxPrepareTime;
 104  
     }
 105  
     public void setMaxPrepareTime(long maxPrepareTime) {
 106  0
         this.maxPrepareTime = maxPrepareTime;
 107  0
     }
 108  
     public long getMinExecuteTime() {
 109  0
     	if(this.noOfExecutes == 0){
 110  0
     		return 0;
 111  
     	}
 112  
     	else{
 113  0
     		return minExecuteTime;
 114  
     	}
 115  
         
 116  
     }
 117  
     public void setMinExecuteTime(long minExecuteTime) {
 118  0
         this.minExecuteTime = minExecuteTime;
 119  0
     }
 120  
     public long getMinPrepareTime() {
 121  0
     	if(this.noOfPrepares == 0){
 122  0
     		return 0;
 123  
     	}
 124  
     	else{
 125  0
     		return minPrepareTime;
 126  
     	}
 127  
         
 128  
     }
 129  
     public void setMinPrepareTime(long minPrepareTime) {
 130  0
         this.minPrepareTime = minPrepareTime;
 131  0
     }
 132  
     public long getNoOfExecutes() {
 133  0
         return noOfExecutes;
 134  
     }
 135  
     public void setNoOfExecutes(long noOfExecutes) {
 136  0
         this.noOfExecutes = noOfExecutes;
 137  0
     }
 138  
     public long getNoOfPrepares() {
 139  0
         return noOfPrepares;
 140  
     }
 141  
     public void setNoOfPrepares(long noOfPrepares) {
 142  0
         this.noOfPrepares = noOfPrepares;
 143  0
     }
 144  
     public String getSql() {
 145  0
         return sql;
 146  
     }
 147  
     public void setSql(String sql) {
 148  0
         this.sql = sql;
 149  0
     }
 150  
     
 151  
     public void mergePrepareTime(AggregateExecutionTime aggrExec){
 152  0
     	if(sql == null){
 153  0
     		setSql(aggrExec.getContext().getName());
 154  
     	}
 155  0
     	if(aggrExec.getTimeOfFirstExecution() < timeOfFirstPrepare ){
 156  0
     		timeOfFirstPrepare = aggrExec.getTimeOfFirstExecution();
 157  0
     		firstPrepareTime = aggrExec.getInclusiveFirstExecutionTime();
 158  
     	}
 159  0
     	if(aggrExec.getTimeOfLastExecution() > timeOfLastPrepare){
 160  0
     		timeOfLastPrepare = aggrExec.getTimeOfLastExecution();
 161  0
     		lastPrepareTime = aggrExec.getInclusiveLastExecutionTime();
 162  
     	}
 163  0
     	if(aggrExec.getMaxInclusiveTime() > maxPrepareTime){
 164  0
     		maxPrepareTime = aggrExec.getMaxInclusiveTime();
 165  
     	}
 166  0
     	if(aggrExec.getMinInclusiveTime() < minPrepareTime){
 167  0
     		minPrepareTime = aggrExec.getMinInclusiveTime();
 168  
     	}
 169  0
     	noOfPrepares+=aggrExec.getExecutionCount();
 170  0
     	totalPrepareTime+=aggrExec.getTotalInclusiveTime();
 171  0
     }
 172  
 
 173  
     public void mergeExecuteTime(AggregateExecutionTime aggrExec){
 174  0
     	if(sql == null){
 175  0
     		setSql(aggrExec.getContext().getName());
 176  
     	}
 177  0
     	if(aggrExec.getTimeOfFirstExecution() < timeOfFirstExecute ){
 178  0
     		timeOfFirstExecute = aggrExec.getTimeOfFirstExecution();
 179  0
     		firstExecuteTime = aggrExec.getInclusiveFirstExecutionTime();
 180  
     	}
 181  0
     	if(aggrExec.getTimeOfLastExecution() > timeOfLastExecute){
 182  0
     		timeOfLastExecute = aggrExec.getTimeOfLastExecution();
 183  0
     		lastExecuteTime = aggrExec.getInclusiveLastExecutionTime();
 184  
     	}
 185  0
     	if(aggrExec.getMaxInclusiveTime() > maxExecuteTime){
 186  0
     		maxExecuteTime = aggrExec.getMaxInclusiveTime();
 187  
     	}
 188  0
     	if(aggrExec.getMinInclusiveTime() < minExecuteTime){
 189  0
     		minExecuteTime = aggrExec.getMinInclusiveTime();
 190  
     	}
 191  0
     	noOfExecutes+=aggrExec.getExecutionCount();
 192  0
     	totalExecuteTime+=aggrExec.getTotalInclusiveTime();
 193  
     	
 194  0
     }
 195  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.