[metrics] Add metrics to Runtime, implement ClassVerificationTotalTime

This creates the main metrics struct and makes it readily accessible for
ART components that want to start collecting metrics. It also implements
the ClassVerificationTime metric.

Test: m test-art-host-gtest-art_runtime_tests
Test: m test-art-host-gtest-art_libartbase_tests
Bug: 170149255
Change-Id: I33b5b2dd40127074619750d6730db220e3ed1257
diff --git a/runtime/runtime.h b/runtime/runtime.h
index 594edaa..9eef7a2 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -21,15 +21,16 @@
 #include <stdio.h>
 
 #include <iosfwd>
+#include <memory>
 #include <set>
 #include <string>
 #include <utility>
-#include <memory>
 #include <vector>
 
 #include "base/locks.h"
 #include "base/macros.h"
 #include "base/mem_map.h"
+#include "base/metrics.h"
 #include "base/string_view_cpp20.h"
 #include "deoptimization_kind.h"
 #include "dex/dex_file_types.h"
@@ -979,6 +980,8 @@
   // Return true if we should load oat files as executable or not.
   bool GetOatFilesExecutable() const;
 
+  metrics::ArtMetrics* GetMetrics() { return &metrics_; }
+
  private:
   static void InitPlatformSignalHandlers();
 
@@ -1334,6 +1337,8 @@
   bool verifier_missing_kthrow_fatal_;
   bool perfetto_hprof_enabled_;
 
+  metrics::ArtMetrics metrics_;
+
   // Note: See comments on GetFaultMessage.
   friend std::string GetFaultMessageForAbortLogging();
   friend class Dex2oatImageTest;
@@ -1344,6 +1349,8 @@
   DISALLOW_COPY_AND_ASSIGN(Runtime);
 };
 
+inline metrics::ArtMetrics* GetMetrics() { return Runtime::Current()->GetMetrics(); }
+
 }  // namespace art
 
 #endif  // ART_RUNTIME_RUNTIME_H_