69 private final CounterKey executionCount; 70 71 /** 72 * Accumulates the {@linkplain Graph#getNodeCount() live node count} of all graphs sent to 73 * {@link #apply(StructuredGraph, Object, boolean)}. 74 */ 75 private final CounterKey inputNodesCount; 76 77 /** 78 * Records memory usage within {@link #apply(StructuredGraph, Object, boolean)}. 79 */ 80 private final MemUseTrackerKey memUseTracker; 81 82 /** Lazy initialization to create pattern only when assertions are enabled. */ 83 static class NamePatternHolder { 84 static final Pattern NAME_PATTERN = Pattern.compile("[A-Z][A-Za-z0-9]+"); 85 } 86 87 public static class BasePhaseStatistics { 88 /** 89 * Records time spent in {@link #apply(StructuredGraph, Object, boolean)}. 90 */ 91 private final TimerKey timer; 92 93 /** 94 * Counts calls to {@link #apply(StructuredGraph, Object, boolean)}. 95 */ 96 private final CounterKey executionCount; 97 98 /** 99 * Accumulates the {@linkplain Graph#getNodeCount() live node count} of all graphs sent to 100 * {@link #apply(StructuredGraph, Object, boolean)}. 101 */ 102 private final CounterKey inputNodesCount; 103 104 /** 105 * Records memory usage within {@link #apply(StructuredGraph, Object, boolean)}. 106 */ 107 private final MemUseTrackerKey memUseTracker; 108 109 public BasePhaseStatistics(Class<?> clazz) { 110 timer = DebugContext.timer("PhaseTime_%s", clazz).doc("Time spent in phase."); 111 executionCount = DebugContext.counter("PhaseCount_%s", clazz).doc("Number of phase executions."); 112 memUseTracker = DebugContext.memUseTracker("PhaseMemUse_%s", clazz).doc("Memory allocated in phase."); 113 inputNodesCount = DebugContext.counter("PhaseNodes_%s", clazz).doc("Number of nodes input to phase."); 114 } 115 } 116 117 private static final ClassValue<BasePhaseStatistics> statisticsClassValue = new ClassValue<BasePhaseStatistics>() { 118 @Override 119 protected BasePhaseStatistics computeValue(Class<?> c) { 120 return new BasePhaseStatistics(c); 121 } 122 }; 123 124 private static BasePhaseStatistics getBasePhaseStatistics(Class<?> c) { 125 return statisticsClassValue.get(c); | 69 private final CounterKey executionCount; 70 71 /** 72 * Accumulates the {@linkplain Graph#getNodeCount() live node count} of all graphs sent to 73 * {@link #apply(StructuredGraph, Object, boolean)}. 74 */ 75 private final CounterKey inputNodesCount; 76 77 /** 78 * Records memory usage within {@link #apply(StructuredGraph, Object, boolean)}. 79 */ 80 private final MemUseTrackerKey memUseTracker; 81 82 /** Lazy initialization to create pattern only when assertions are enabled. */ 83 static class NamePatternHolder { 84 static final Pattern NAME_PATTERN = Pattern.compile("[A-Z][A-Za-z0-9]+"); 85 } 86 87 public static class BasePhaseStatistics { 88 /** 89 * Records time spent in {@link BasePhase#apply(StructuredGraph, Object, boolean)}. 90 */ 91 private final TimerKey timer; 92 93 /** 94 * Counts calls to {@link BasePhase#apply(StructuredGraph, Object, boolean)}. 95 */ 96 private final CounterKey executionCount; 97 98 /** 99 * Accumulates the {@linkplain Graph#getNodeCount() live node count} of all graphs sent to 100 * {@link BasePhase#apply(StructuredGraph, Object, boolean)}. 101 */ 102 private final CounterKey inputNodesCount; 103 104 /** 105 * Records memory usage within {@link BasePhase#apply(StructuredGraph, Object, boolean)}. 106 */ 107 private final MemUseTrackerKey memUseTracker; 108 109 public BasePhaseStatistics(Class<?> clazz) { 110 timer = DebugContext.timer("PhaseTime_%s", clazz).doc("Time spent in phase."); 111 executionCount = DebugContext.counter("PhaseCount_%s", clazz).doc("Number of phase executions."); 112 memUseTracker = DebugContext.memUseTracker("PhaseMemUse_%s", clazz).doc("Memory allocated in phase."); 113 inputNodesCount = DebugContext.counter("PhaseNodes_%s", clazz).doc("Number of nodes input to phase."); 114 } 115 } 116 117 private static final ClassValue<BasePhaseStatistics> statisticsClassValue = new ClassValue<BasePhaseStatistics>() { 118 @Override 119 protected BasePhaseStatistics computeValue(Class<?> c) { 120 return new BasePhaseStatistics(c); 121 } 122 }; 123 124 private static BasePhaseStatistics getBasePhaseStatistics(Class<?> c) { 125 return statisticsClassValue.get(c); |