Coverage Report - net.admin4j.hotspot.HotSpotUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
HotSpotUtils
87%
7/8
100%
2/2
1.333
 
 1  
 /*
 2  
  * This software is licensed under the Apache License, Version 2.0
 3  
  * (the "License") agreement; you may not use this file except in compliance with
 4  
  * the License.  You may obtain a copy of the License at
 5  
  * 
 6  
  *      http://www.apache.org/licenses/LICENSE-2.0
 7  
  * 
 8  
  * Unless required by applicable law or agreed to in writing, software
 9  
  * distributed under the License is distributed on an "AS IS" BASIS,
 10  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 11  
  * See the License for the specific language governing permissions and
 12  
  * limitations under the License.
 13  
  */
 14  
 package net.admin4j.hotspot;
 15  
 
 16  
 import java.util.List;
 17  
 import java.util.Map;
 18  
 
 19  
 import net.admin4j.deps.commons.lang3.Validate;
 20  
 import net.admin4j.entity.ExecutionPoint;
 21  
 
 22  
 /**
 23  
  * General utilities needed for the HotSpot display. 
 24  
  * @author D. Ashmore
 25  
  *
 26  
  */
 27  
 public class HotSpotUtils {
 28  
     
 29  
     private Map<StackTraceElement, ExecutionPoint> executionMap;
 30  
     
 31  3
     public HotSpotUtils(Map<StackTraceElement, ExecutionPoint> executionMap) {
 32  
         Validate.notNull(executionMap, "Null executionMap not allowed.");
 33  3
         this.executionMap = executionMap;
 34  3
     }
 35  
     
 36  
     public double computeExecutionPct(List<ExecutionPoint> pointList, ExecutionPoint point) {
 37  6
         long total = 0;
 38  6
         for (ExecutionPoint p: pointList) {
 39  6
             total += p.getNbrExecutions();
 40  
         }
 41  
         
 42  6
         return ((double)point.getNbrExecutions() / (double)total) * (double)100.000;
 43  
     }
 44  
     
 45  
     public ExecutionPoint findExecutionPoint(StackTraceElement element) {
 46  0
         return this.executionMap.get(element);
 47  
     }
 48  
 
 49  
 }