OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 5694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5706 PrintF("Timing results:\n"); | 5706 PrintF("Timing results:\n"); |
5707 int64_t sum = 0; | 5707 int64_t sum = 0; |
5708 for (int i = 0; i < timing_.length(); ++i) { | 5708 for (int i = 0; i < timing_.length(); ++i) { |
5709 sum += timing_[i]; | 5709 sum += timing_[i]; |
5710 } | 5710 } |
5711 | 5711 |
5712 for (int i = 0; i < names_.length(); ++i) { | 5712 for (int i = 0; i < names_.length(); ++i) { |
5713 PrintF("%30s", names_[i]); | 5713 PrintF("%30s", names_[i]); |
5714 double ms = static_cast<double>(timing_[i]) / 1000; | 5714 double ms = static_cast<double>(timing_[i]) / 1000; |
5715 double percent = static_cast<double>(timing_[i]) * 100 / sum; | 5715 double percent = static_cast<double>(timing_[i]) * 100 / sum; |
5716 PrintF(" - %0.3f ms / %0.3f %% \n", ms, percent); | 5716 PrintF(" - %7.3f ms / %4.1f %% ", ms, percent); |
| 5717 |
| 5718 unsigned size = sizes_[i]; |
| 5719 double size_percent = static_cast<double>(size) * 100 / total_size_; |
| 5720 PrintF(" %8u bytes / %4.1f %%\n", size, size_percent); |
5717 } | 5721 } |
5718 PrintF("%30s - %0.3f ms \n", "Sum", static_cast<double>(sum) / 1000); | 5722 PrintF("%30s - %7.3f ms %8u bytes\n", "Sum", |
| 5723 static_cast<double>(sum) / 1000, |
| 5724 total_size_); |
5719 PrintF("---------------------------------------------------------------\n"); | 5725 PrintF("---------------------------------------------------------------\n"); |
5720 PrintF("%30s - %0.3f ms (%0.1f times slower than full code gen)\n", | 5726 PrintF("%30s - %7.3f ms (%.1f times slower than full code gen)\n", |
5721 "Total", | 5727 "Total", |
5722 static_cast<double>(total_) / 1000, | 5728 static_cast<double>(total_) / 1000, |
5723 static_cast<double>(total_) / full_code_gen_); | 5729 static_cast<double>(total_) / full_code_gen_); |
5724 } | 5730 } |
5725 | 5731 |
5726 | 5732 |
5727 void HStatistics::SaveTiming(const char* name, int64_t ticks) { | 5733 void HStatistics::SaveTiming(const char* name, int64_t ticks, unsigned size) { |
5728 if (name == HPhase::kFullCodeGen) { | 5734 if (name == HPhase::kFullCodeGen) { |
5729 full_code_gen_ += ticks; | 5735 full_code_gen_ += ticks; |
5730 } else if (name == HPhase::kTotal) { | 5736 } else if (name == HPhase::kTotal) { |
5731 total_ += ticks; | 5737 total_ += ticks; |
5732 } else { | 5738 } else { |
| 5739 total_size_ += size; |
5733 for (int i = 0; i < names_.length(); ++i) { | 5740 for (int i = 0; i < names_.length(); ++i) { |
5734 if (names_[i] == name) { | 5741 if (names_[i] == name) { |
5735 timing_[i] += ticks; | 5742 timing_[i] += ticks; |
| 5743 sizes_[i] += size; |
5736 return; | 5744 return; |
5737 } | 5745 } |
5738 } | 5746 } |
5739 names_.Add(name); | 5747 names_.Add(name); |
5740 timing_.Add(ticks); | 5748 timing_.Add(ticks); |
| 5749 sizes_.Add(size); |
5741 } | 5750 } |
5742 } | 5751 } |
5743 | 5752 |
5744 | 5753 |
5745 const char* const HPhase::kFullCodeGen = "Full code generator"; | 5754 const char* const HPhase::kFullCodeGen = "Full code generator"; |
5746 const char* const HPhase::kTotal = "Total"; | 5755 const char* const HPhase::kTotal = "Total"; |
5747 | 5756 |
5748 | 5757 |
5749 void HPhase::Begin(const char* name, | 5758 void HPhase::Begin(const char* name, |
5750 HGraph* graph, | 5759 HGraph* graph, |
5751 LChunk* chunk, | 5760 LChunk* chunk, |
5752 LAllocator* allocator) { | 5761 LAllocator* allocator) { |
5753 name_ = name; | 5762 name_ = name; |
5754 graph_ = graph; | 5763 graph_ = graph; |
5755 chunk_ = chunk; | 5764 chunk_ = chunk; |
5756 allocator_ = allocator; | 5765 allocator_ = allocator; |
5757 if (allocator != NULL && chunk_ == NULL) { | 5766 if (allocator != NULL && chunk_ == NULL) { |
5758 chunk_ = allocator->chunk(); | 5767 chunk_ = allocator->chunk(); |
5759 } | 5768 } |
5760 if (FLAG_time_hydrogen) start_ = OS::Ticks(); | 5769 if (FLAG_time_hydrogen) start_ = OS::Ticks(); |
| 5770 start_allocation_size_ = Zone::allocation_size_; |
5761 } | 5771 } |
5762 | 5772 |
5763 | 5773 |
5764 void HPhase::End() const { | 5774 void HPhase::End() const { |
5765 if (FLAG_time_hydrogen) { | 5775 if (FLAG_time_hydrogen) { |
5766 int64_t end = OS::Ticks(); | 5776 int64_t end = OS::Ticks(); |
5767 HStatistics::Instance()->SaveTiming(name_, end - start_); | 5777 unsigned size = Zone::allocation_size_ - start_allocation_size_; |
| 5778 HStatistics::Instance()->SaveTiming(name_, end - start_, size); |
5768 } | 5779 } |
5769 | 5780 |
5770 if (FLAG_trace_hydrogen) { | 5781 if (FLAG_trace_hydrogen) { |
5771 if (graph_ != NULL) HTracer::Instance()->TraceHydrogen(name_, graph_); | 5782 if (graph_ != NULL) HTracer::Instance()->TraceHydrogen(name_, graph_); |
5772 if (chunk_ != NULL) HTracer::Instance()->TraceLithium(name_, chunk_); | 5783 if (chunk_ != NULL) HTracer::Instance()->TraceLithium(name_, chunk_); |
5773 if (allocator_ != NULL) { | 5784 if (allocator_ != NULL) { |
5774 HTracer::Instance()->TraceLiveRanges(name_, allocator_); | 5785 HTracer::Instance()->TraceLiveRanges(name_, allocator_); |
5775 } | 5786 } |
5776 } | 5787 } |
5777 | 5788 |
5778 #ifdef DEBUG | 5789 #ifdef DEBUG |
5779 if (graph_ != NULL) graph_->Verify(); | 5790 if (graph_ != NULL) graph_->Verify(); |
5780 if (chunk_ != NULL) chunk_->Verify(); | 5791 if (chunk_ != NULL) chunk_->Verify(); |
5781 if (allocator_ != NULL) allocator_->Verify(); | 5792 if (allocator_ != NULL) allocator_->Verify(); |
5782 #endif | 5793 #endif |
5783 } | 5794 } |
5784 | 5795 |
5785 } } // namespace v8::internal | 5796 } } // namespace v8::internal |
OLD | NEW |