Normalize statistics about compilation time and allocation size.
authorfschneider@chromium.org <fschneider@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 10 Mar 2011 13:26:51 +0000 (13:26 +0000)
committerfschneider@chromium.org <fschneider@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 10 Mar 2011 13:26:51 +0000 (13:26 +0000)
Now we print compilation time and zone allocation per KB of compiled
source code to better compare with previous revisions.

Review URL: http://codereview.chromium.org/6646015

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7128 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/compiler.cc
src/flag-definitions.h
src/hydrogen.cc
src/hydrogen.h
src/v8.cc

index 667432f22fdba431731faac445fbcf16bf1c02e4..3f0534c39be2f66e9d26ad0d1fa56c542399a6ed 100755 (executable)
@@ -248,7 +248,7 @@ static bool MakeCrankshaftCode(CompilationInfo* info) {
   // performance of the hydrogen-based compiler.
   int64_t start = OS::Ticks();
   bool should_recompile = !info->shared_info()->has_deoptimization_support();
-  if (should_recompile || FLAG_time_hydrogen) {
+  if (should_recompile || FLAG_hydrogen_stats) {
     HPhase phase(HPhase::kFullCodeGen);
     CompilationInfo unoptimized(info->shared_info());
     // Note that we use the same AST that we will use for generating the
index 2566766e3c8d5290c043d2a9efd853f96a59bed0..cdad211cd61287f19d5d16b7e16ac7d9e2b9d479 100644 (file)
@@ -111,7 +111,7 @@ DEFINE_bool(use_inlining, true, "use function inlining")
 DEFINE_bool(limit_inlining, true, "limit code size growth from inlining")
 DEFINE_bool(eliminate_empty_blocks, true, "eliminate empty blocks")
 DEFINE_bool(loop_invariant_code_motion, true, "loop invariant code motion")
-DEFINE_bool(time_hydrogen, false, "timing for hydrogen")
+DEFINE_bool(hydrogen_stats, false, "print statistics for hydrogen")
 DEFINE_bool(trace_hydrogen, false, "trace generated hydrogen to file")
 DEFINE_bool(trace_inlining, false, "trace inlining decisions")
 DEFINE_bool(trace_alloc, false, "trace register allocator")
index b879909e53e1c83b13b2edbc9e441fe37a40133a..e47712eb750fd8ef4efdd6f1f32e2054b1b10856 100644 (file)
@@ -2134,6 +2134,8 @@ void HGraphBuilder::VisitExpressions(ZoneList<Expression*>* exprs) {
 
 HGraph* HGraphBuilder::CreateGraph() {
   graph_ = new HGraph(info());
+  if (FLAG_hydrogen_stats) HStatistics::Instance()->Initialize(info());
+
   {
     HPhase phase("Block building");
     current_block_ = graph()->entry_block();
@@ -5810,6 +5812,11 @@ void HTracer::FlushToFile() {
 }
 
 
+void HStatistics::Initialize(CompilationInfo* info) {
+  source_size_ += info->shared_info()->SourceSize();
+}
+
+
 void HStatistics::Print() {
   PrintF("Timing results:\n");
   int64_t sum = 0;
@@ -5827,9 +5834,10 @@ void HStatistics::Print() {
     double size_percent = static_cast<double>(size) * 100 / total_size_;
     PrintF(" %8u bytes / %4.1f %%\n", size, size_percent);
   }
-  PrintF("%30s - %7.3f ms           %8u bytes\n", "Sum",
-         static_cast<double>(sum) / 1000,
-         total_size_);
+  double source_size_in_kb = static_cast<double>(source_size_) / 1024;
+  PrintF("%30s - %7.3f ms           %7.3f bytes\n", "Sum",
+         (static_cast<double>(sum) / 1000) / source_size_in_kb,
+         total_size_ / source_size_in_kb);
   PrintF("---------------------------------------------------------------\n");
   PrintF("%30s - %7.3f ms (%.1f times slower than full code gen)\n",
          "Total",
@@ -5874,13 +5882,13 @@ void HPhase::Begin(const char* name,
   if (allocator != NULL && chunk_ == NULL) {
     chunk_ = allocator->chunk();
   }
-  if (FLAG_time_hydrogen) start_ = OS::Ticks();
+  if (FLAG_hydrogen_stats) start_ = OS::Ticks();
   start_allocation_size_ = Zone::allocation_size_;
 }
 
 
 void HPhase::End() const {
-  if (FLAG_time_hydrogen) {
+  if (FLAG_hydrogen_stats) {
     int64_t end = OS::Ticks();
     unsigned size = Zone::allocation_size_ - start_allocation_size_;
     HStatistics::Instance()->SaveTiming(name_, end - start_, size);
index 21f36773d0584d0282a712aa399ceb709912b99b..235b669933294a6d890ba0d099d2f77d41d11e2f 100644 (file)
@@ -939,6 +939,7 @@ class HValueMap: public ZoneObject {
 
 class HStatistics: public Malloced {
  public:
+  void Initialize(CompilationInfo* info);
   void Print();
   void SaveTiming(const char* name, int64_t ticks, unsigned size);
   static HStatistics* Instance() {
@@ -957,7 +958,8 @@ class HStatistics: public Malloced {
         sizes_(5),
         total_(0),
         total_size_(0),
-        full_code_gen_(0) { }
+        full_code_gen_(0),
+        source_size_(0) { }
 
   List<int64_t> timing_;
   List<const char*> names_;
@@ -965,6 +967,7 @@ class HStatistics: public Malloced {
   int64_t total_;
   unsigned total_size_;
   int64_t full_code_gen_;
+  double source_size_;
 };
 
 
index 945043da9bc23cd100dae7fefea8facbdf0181ad..27648b144a44fd6b3cfa2ded0a23e451aa3d88c0 100644 (file)
--- a/src/v8.cc
+++ b/src/v8.cc
@@ -158,7 +158,7 @@ void V8::SetFatalError() {
 void V8::TearDown() {
   if (!has_been_setup_ || has_been_disposed_) return;
 
-  if (FLAG_time_hydrogen) HStatistics::Instance()->Print();
+  if (FLAG_hydrogen_stats) HStatistics::Instance()->Print();
 
   // We must stop the logger before we tear down other components.
   Logger::EnsureTickerStopped();