[metrics] Implement JitMethodCompileTime histogram
JitMethodCompileTime keeps track of how long methods take to compile in
JIT mode.
Test: m test-art-host-gtest-art_libartbase_tests
Bug: 170149255
Change-Id: Ic0e5f365d9e7eb7bc0ebcf49d23972adcd6dfb36
diff --git a/compiler/jit/jit_compiler.cc b/compiler/jit/jit_compiler.cc
index b254c57..10aa306 100644
--- a/compiler/jit/jit_compiler.cc
+++ b/compiler/jit/jit_compiler.cc
@@ -188,14 +188,12 @@
: "Compiling baseline",
&logger);
JitCodeCache* const code_cache = runtime->GetJit()->GetCodeCache();
- uint64_t start_ns = NanoTime();
+ metrics::AutoTimer timer{runtime->GetMetrics()->JitMethodCompileTime()};
success = compiler_->JitCompile(
self, code_cache, region, method, compilation_kind, jit_logger_.get());
- uint64_t duration_ns = NanoTime() - start_ns;
- VLOG(jit) << "Compilation of "
- << method->PrettyMethod()
- << " took "
- << PrettyDuration(duration_ns);
+ uint64_t duration_us = timer.Stop();
+ VLOG(jit) << "Compilation of " << method->PrettyMethod() << " took "
+ << PrettyDuration(UsToNs(duration_us));
}
// Trim maps to reduce memory usage.
diff --git a/libartbase/base/metrics.h b/libartbase/base/metrics.h
index f2852b4..119f622 100644
--- a/libartbase/base/metrics.h
+++ b/libartbase/base/metrics.h
@@ -48,7 +48,6 @@
// side are infinitely long). If we see those buckets being way taller than the others, it means we
// should consider expanding the range.
#define ART_HISTOGRAMS(HISTOGRAM) HISTOGRAM(JitMethodCompileTime, 15, 0, 1'000'000)
-// TODO: JitMethodCompileTime serves as a mock for now. Implementation will come later.
// A lot of the metrics implementation code is generated by passing one-off macros into ART_COUNTERS
// and ART_HISTOGRAMS. This means metrics.h and metrics.cc are very #define-heavy, which can be
diff --git a/runtime/verifier/class_verifier.cc b/runtime/verifier/class_verifier.cc
index d725a58..571651a 100644
--- a/runtime/verifier/class_verifier.cc
+++ b/runtime/verifier/class_verifier.cc
@@ -305,7 +305,7 @@
failure_data.Merge(result);
}
uint64_t elapsed_time_microseconds = timer.Stop();
- VLOG(verifier) << "VerifyClass took " << PrettyDuration(elapsed_time_microseconds * 1000)
+ VLOG(verifier) << "VerifyClass took " << PrettyDuration(UsToNs(elapsed_time_microseconds))
<< ", class: " << PrettyDescriptor(dex_file->GetClassDescriptor(class_def));
if (failure_data.kind == FailureKind::kNoFailure) {