1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
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 | |
|
24 | |
|
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 | |
} |