Move TimingLogger creation to dex2oat

Change-Id: I4fdb6afd4ce2ac0d91c6c968893606d593b6ea18
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 6558f8a..b1b205e 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -335,7 +335,7 @@
 
 CompilerDriver::CompilerDriver(CompilerBackend compiler_backend, InstructionSet instruction_set,
                                bool image, DescriptorSet* image_classes,
-                               size_t thread_count, bool dump_stats, bool dump_timings)
+                               size_t thread_count, bool dump_stats)
     : compiler_backend_(compiler_backend),
       instruction_set_(instruction_set),
       freezing_constructor_lock_("freezing constructor lock"),
@@ -347,7 +347,6 @@
       start_ns_(0),
       stats_(new AOTCompilationStats),
       dump_stats_(dump_stats),
-      dump_timings_(dump_timings),
       compiler_library_(NULL),
       compiler_(NULL),
       compiler_context_(NULL),
@@ -495,20 +494,12 @@
 }
 
 void CompilerDriver::CompileAll(jobject class_loader,
-                                const std::vector<const DexFile*>& dex_files) {
+                                const std::vector<const DexFile*>& dex_files,
+                                TimingLogger& timings) {
   DCHECK(!Runtime::Current()->IsStarted());
-
   UniquePtr<ThreadPool> thread_pool(new ThreadPool(thread_count_));
-  TimingLogger timings("compiler", false);
-
   PreCompile(class_loader, dex_files, *thread_pool.get(), timings);
-
   Compile(class_loader, dex_files, *thread_pool.get(), timings);
-
-  if (dump_timings_ && timings.GetTotalNs() > MsToNs(1000)) {
-    LOG(INFO) << Dumpable<TimingLogger>(timings);
-  }
-
   if (dump_stats_) {
     stats_->Dump();
   }
@@ -537,7 +528,7 @@
   return klass->IsVerified();
 }
 
-void CompilerDriver::CompileOne(const mirror::AbstractMethod* method) {
+void CompilerDriver::CompileOne(const mirror::AbstractMethod* method, TimingLogger& timings) {
   DCHECK(!Runtime::Current()->IsStarted());
   Thread* self = Thread::Current();
   jobject jclass_loader;
@@ -560,7 +551,6 @@
   dex_files.push_back(dex_file);
 
   UniquePtr<ThreadPool> thread_pool(new ThreadPool(1U));
-  TimingLogger timings("CompileOne", false);
   PreCompile(jclass_loader, dex_files, *thread_pool.get(), timings);
 
   uint32_t method_idx = method->GetDexMethodIndex();
diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h
index 902fda7..1799057 100644
--- a/compiler/driver/compiler_driver.h
+++ b/compiler/driver/compiler_driver.h
@@ -72,15 +72,16 @@
   // classes.
   explicit CompilerDriver(CompilerBackend compiler_backend, InstructionSet instruction_set,
                           bool image, DescriptorSet* image_classes,
-                          size_t thread_count, bool dump_stats, bool dump_timings);
+                          size_t thread_count, bool dump_stats);
 
   ~CompilerDriver();
 
-  void CompileAll(jobject class_loader, const std::vector<const DexFile*>& dex_files)
+  void CompileAll(jobject class_loader, const std::vector<const DexFile*>& dex_files,
+                  TimingLogger& timings)
       LOCKS_EXCLUDED(Locks::mutator_lock_);
 
   // Compile a single Method
-  void CompileOne(const mirror::AbstractMethod* method)
+  void CompileOne(const mirror::AbstractMethod* method, TimingLogger& timings)
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
 
   InstructionSet GetInstructionSet() const {
@@ -362,7 +363,6 @@
   UniquePtr<AOTCompilationStats> stats_;
 
   bool dump_stats_;
-  bool dump_timings_;
 
   typedef void (*CompilerCallbackFn)(CompilerDriver& driver);
   typedef MutexLock* (*CompilerMutexLockFn)(CompilerDriver& driver);
diff --git a/compiler/driver/compiler_driver_test.cc b/compiler/driver/compiler_driver_test.cc
index 6a160f7..78cacaf 100644
--- a/compiler/driver/compiler_driver_test.cc
+++ b/compiler/driver/compiler_driver_test.cc
@@ -36,7 +36,10 @@
 class CompilerDriverTest : public CommonTest {
  protected:
   void CompileAll(jobject class_loader) LOCKS_EXCLUDED(Locks::mutator_lock_) {
-    compiler_driver_->CompileAll(class_loader, Runtime::Current()->GetCompileTimeClassPath(class_loader));
+    TimingLogger timings("CompilerDriverTest::CompileAll", false);
+    compiler_driver_->CompileAll(class_loader,
+                                 Runtime::Current()->GetCompileTimeClassPath(class_loader),
+                                 timings);
     MakeAllExecutable(class_loader);
   }