[metrics] Improve metrics definition API

This CL combines the ART_COUNTERS and ART_HISTOGRAMS lists into a
single ART_METRICS list. Additionally, this will make it possible to
add additional metrics types with less boilerplate.

Bug: 170149255
Test: gtests
Change-Id: I09e161de1ae574dfcc9ab95e8827b071f0a53892
diff --git a/libartbase/base/metrics/metrics_common.cc b/libartbase/base/metrics/metrics_common.cc
index c29605e..0c2ec09 100644
--- a/libartbase/base/metrics/metrics_common.cc
+++ b/libartbase/base/metrics/metrics_common.cc
@@ -30,17 +30,11 @@
 
 std::string DatumName(DatumId datum) {
   switch (datum) {
-#define ART_COUNTER(name) \
+#define ART_METRIC(name, Kind, ...) \
   case DatumId::k##name:  \
     return #name;
-    ART_COUNTERS(ART_COUNTER)
-#undef ART_COUNTER
-
-#define ART_HISTOGRAM(name, num_buckets, low_value, high_value) \
-  case DatumId::k##name:                                        \
-    return #name;
-    ART_HISTOGRAMS(ART_HISTOGRAM)
-#undef ART_HISTOGRAM
+    ART_METRICS(ART_METRIC)
+#undef ART_METRIC
 
     default:
       LOG(FATAL) << "Unknown datum id: " << static_cast<unsigned>(datum);
@@ -64,29 +58,19 @@
 }
 
 ArtMetrics::ArtMetrics() : beginning_timestamp_ {MilliTime()}
-#define ART_COUNTER(name) \
+#define ART_METRIC(name, Kind, ...) \
   , name##_ {}
-ART_COUNTERS(ART_COUNTER)
-#undef ART_COUNTER
-#define ART_HISTOGRAM(name, num_buckets, low_value, high_value) \
-  , name##_ {}
-ART_HISTOGRAMS(ART_HISTOGRAM)
-#undef ART_HISTOGRAM
+ART_METRICS(ART_METRIC)
+#undef ART_METRIC
 {
 }
 
 void ArtMetrics::ReportAllMetrics(MetricsBackend* backend) const {
   backend->BeginReport(MilliTime() - beginning_timestamp_);
 
-// Dump counters
-#define ART_COUNTER(name) name()->Report(backend);
-  ART_COUNTERS(ART_COUNTER)
-#undef ART_COUNTERS
-
-// Dump histograms
-#define ART_HISTOGRAM(name, num_buckets, low_value, high_value) name()->Report(backend);
-  ART_HISTOGRAMS(ART_HISTOGRAM)
-#undef ART_HISTOGRAM
+#define ART_METRIC(name, Kind, ...) name()->Report(backend);
+  ART_METRICS(ART_METRIC)
+#undef ART_METRICS
 
   backend->EndReport();
 }