use of org.robolectric.AndroidMetadata in project robolectric by robolectric.
the class SimplePerfStatsReporter method finalReport.
@SuppressWarnings("AndroidJdkLibsChecker)")
private synchronized void finalReport() {
Map<MetricKey, MetricValue> mergedMetrics = new TreeMap<>();
for (Data perfStatsData : perfStatsData) {
AndroidMetadata metadata = perfStatsData.metadata.get(AndroidMetadata.class);
Map<String, String> deviceBootProperties = metadata.getDeviceBootProperties();
int sdkInt = Integer.parseInt(deviceBootProperties.get("ro.build.version.sdk"));
String resourcesMode = metadata.getResourcesMode();
for (Metric metric : perfStatsData.metrics) {
MetricKey key = new MetricKey(metric.getName(), metric.isSuccess(), sdkInt, resourcesMode);
MetricValue mergedMetric = mergedMetrics.get(key);
if (mergedMetric == null) {
mergedMetric = new MetricValue();
mergedMetrics.put(key, mergedMetric);
}
mergedMetric.report(metric);
}
}
System.out.println("Name\tSDK\tResources\tSuccess\tCount\tMin ms\tMax ms\tAvg ms\tTotal ms");
for (Entry<MetricKey, MetricValue> entry : mergedMetrics.entrySet()) {
MetricKey key = entry.getKey();
MetricValue value = entry.getValue();
System.out.println(MessageFormat.format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}", key.name, key.sdkLevel, key.resourcesMode, key.success, value.count, (int) (value.minNs / 1000000), (int) (value.maxNs / 1000000), (int) (value.elapsedNs / 1000000 / value.count), (int) (value.elapsedNs / 1000000)));
}
}
Aggregations