ART: Report cputime in dex2oat
Add ProcessCpuNanoTime. Log cputime in dex2oat completion message.
Sample:
dex2oat took 20.036s(64.843s cpu) (threads: 48) arena alloc=25MB (26760672B) java alloc=2MB (2311688B) native alloc=44MB (46792784B) free=35MB (37502896B)
Test: m test-art-host
Change-Id: I78646c4808c8205f7f8e7995a82a1ba63cd15298
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 264be99..0edbd11 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -518,6 +518,7 @@
runtime_(nullptr),
thread_count_(sysconf(_SC_NPROCESSORS_CONF)),
start_ns_(NanoTime()),
+ start_cputime_ns_(ProcessCpuNanoTime()),
oat_fd_(-1),
input_vdex_fd_(-1),
output_vdex_fd_(-1),
@@ -2595,7 +2596,9 @@
// Note: when creation of a runtime fails, e.g., when trying to compile an app but when there
// is no image, there won't be a Runtime::Current().
// Note: driver creation can fail when loading an invalid dex file.
- LOG(INFO) << "dex2oat took " << PrettyDuration(NanoTime() - start_ns_)
+ LOG(INFO) << "dex2oat took "
+ << PrettyDuration(NanoTime() - start_ns_)
+ << "(" << PrettyDuration(ProcessCpuNanoTime() - start_cputime_ns_) << " cpu)"
<< " (threads: " << thread_count_ << ") "
<< ((Runtime::Current() != nullptr && driver_ != nullptr) ?
driver_->GetMemoryUsageString(kIsDebugBuild || VLOG_IS_ON(compiler)) :
@@ -2643,6 +2646,7 @@
size_t thread_count_;
uint64_t start_ns_;
+ uint64_t start_cputime_ns_;
std::unique_ptr<WatchDog> watchdog_;
std::vector<std::unique_ptr<File>> oat_files_;
std::vector<std::unique_ptr<File>> vdex_files_;