Mercurial > hg > truffle
comparison graal/com.oracle.max.base/src/com/sun/max/profile/GlobalMetrics.java @ 4142:bc8527f3071c
Adjust code base to new level of warnings.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sun, 18 Dec 2011 05:24:06 +0100 |
parents | e233f5660da4 |
children |
comparison
equal
deleted
inserted
replaced
4141:04d21be7a24f | 4142:bc8527f3071c |
---|---|
37 return String.CASE_INSENSITIVE_ORDER.compare(a.getKey(), b.getKey()); | 37 return String.CASE_INSENSITIVE_ORDER.compare(a.getKey(), b.getKey()); |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 static class MetricSet<T extends Metric> { | 41 static class MetricSet<T extends Metric> { |
42 private final Class<T> clazz; | 42 protected final Class<T> clazz; |
43 private final Map<String, T> metrics = new HashMap<String, T>(); | 43 private final Map<String, T> metrics = new HashMap<>(); |
44 | 44 |
45 MetricSet(Class<T> mClass) { | 45 MetricSet(Class<T> mClass) { |
46 clazz = mClass; | 46 clazz = mClass; |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
50 protected static final Map<Class<? extends Metric>, MetricSet> metricSets = new HashMap<Class<? extends Metric>, MetricSet>(); | 50 protected static final Map<Class<? extends Metric>, MetricSet> metricSets = new HashMap<>(); |
51 | 51 |
52 /** | 52 /** |
53 * This method allocates a new counter with the specified name and adds it to the global | 53 * This method allocates a new counter with the specified name and adds it to the global |
54 * metric list. If a previous metric with the same name exists, it will return a reference | 54 * metric list. If a previous metric with the same name exists, it will return a reference |
55 * to the first one created. | 55 * to the first one created. |
113 } | 113 } |
114 | 114 |
115 public static <T extends Metric> T setMetric(String name, Class<T> mClass, T metric) { | 115 public static <T extends Metric> T setMetric(String name, Class<T> mClass, T metric) { |
116 MetricSet<T> metricSet = Utils.cast(metricSets.get(mClass)); | 116 MetricSet<T> metricSet = Utils.cast(metricSets.get(mClass)); |
117 if (metricSet == null) { | 117 if (metricSet == null) { |
118 metricSet = new MetricSet<T>(mClass); | 118 metricSet = new MetricSet<>(mClass); |
119 metricSets.put(mClass, metricSet); | 119 metricSets.put(mClass, metricSet); |
120 } | 120 } |
121 metricSet.metrics.put(name, metric); | 121 metricSet.metrics.put(name, metric); |
122 return metric; | 122 return metric; |
123 } | 123 } |
137 * This method prints a report of all the metrics that have been created during this | 137 * This method prints a report of all the metrics that have been created during this |
138 * execution run. | 138 * execution run. |
139 * @param stream the print stream to which to print the report | 139 * @param stream the print stream to which to print the report |
140 */ | 140 */ |
141 public static synchronized void report(PrintStream stream) { | 141 public static synchronized void report(PrintStream stream) { |
142 final Map<String, Metric> allMetrics = new HashMap<String, Metric>(); | 142 final Map<String, Metric> allMetrics = new HashMap<>(); |
143 for (MetricSet<? extends Metric> metricSet : metricSets.values()) { | 143 for (MetricSet<? extends Metric> metricSet : metricSets.values()) { |
144 allMetrics.putAll(metricSet.metrics); | 144 allMetrics.putAll(metricSet.metrics); |
145 } | 145 } |
146 | 146 |
147 Map.Entry<String, Metric>[] array = Utils.cast(new Map.Entry[allMetrics.size()]); | 147 Map.Entry<String, Metric>[] array = Utils.cast(new Map.Entry[allMetrics.size()]); |