Add an execution time log for VerifyClass
Some APK gets a very small duration of VerifyClass. We cannot use
systrace to profile it because the value is too small. The log
measurement can get a better precise value.
Test APK: com.babycloud.hanju
Systrace enable
VerifyClass count: 1122
Q: 365.864ms
R: 411.979ms
Systrace disable
VerifyClass count: 1122
Q: 325.234ms
R: 337.045ms
Via above results, systrace disable can get a better precise value.
Sample:
06-23 21:14:06.338 5199 5199 I babycloud.hanj: VerifyClass took
1.509ms, class: androidx.fragment.app.FragmentTransition
Test: boot
Test: Launch APP
Change-Id: I4375b42f07bc48987c3c4ffa1c155c2c748a7a65
diff --git a/runtime/verifier/class_verifier.cc b/runtime/verifier/class_verifier.cc
index ed83652..386e490 100644
--- a/runtime/verifier/class_verifier.cc
+++ b/runtime/verifier/class_verifier.cc
@@ -242,6 +242,10 @@
ClassAccessor accessor(*dex_file, class_def);
SCOPED_TRACE << "VerifyClass " << PrettyDescriptor(accessor.GetDescriptor());
+ uint64_t start_ns = 0u;
+ if (VLOG_IS_ON(verifier)) {
+ start_ns = NanoTime();
+ }
int64_t previous_method_idx[2] = { -1, -1 };
MethodVerifier::FailureData failure_data;
@@ -303,6 +307,8 @@
}
failure_data.Merge(result);
}
+ VLOG(verifier) << "VerifyClass took " << PrettyDuration(NanoTime() - start_ns)
+ << ", class: " << PrettyDescriptor(dex_file->GetClassDescriptor(class_def));
if (failure_data.kind == FailureKind::kNoFailure) {
return FailureKind::kNoFailure;