Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <ostream> // NOLINT(readability/streams) | 5 #include <ostream> // NOLINT(readability/streams) |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "src/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" |
| 9 #include "src/compilation-statistics.h" | 9 #include "src/compilation-statistics.h" |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 void CompilationStatistics::BasicStats::Accumulate(const BasicStats& stats) { | 47 void CompilationStatistics::BasicStats::Accumulate(const BasicStats& stats) { |
| 48 delta_ += stats.delta_; | 48 delta_ += stats.delta_; |
| 49 total_allocated_bytes_ += stats.total_allocated_bytes_; | 49 total_allocated_bytes_ += stats.total_allocated_bytes_; |
| 50 if (stats.absolute_max_allocated_bytes_ > absolute_max_allocated_bytes_) { | 50 if (stats.absolute_max_allocated_bytes_ > absolute_max_allocated_bytes_) { |
| 51 absolute_max_allocated_bytes_ = stats.absolute_max_allocated_bytes_; | 51 absolute_max_allocated_bytes_ = stats.absolute_max_allocated_bytes_; |
| 52 max_allocated_bytes_ = stats.max_allocated_bytes_; | 52 max_allocated_bytes_ = stats.max_allocated_bytes_; |
| 53 function_name_ = stats.function_name_; | 53 function_name_ = stats.function_name_; |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 | 57 static void WriteLine(std::ostream& os, bool machine_format, const char* name, |
| 58 static void WriteLine(std::ostream& os, const char* name, | |
| 59 const CompilationStatistics::BasicStats& stats, | 58 const CompilationStatistics::BasicStats& stats, |
| 60 const CompilationStatistics::BasicStats& total_stats) { | 59 const CompilationStatistics::BasicStats& total_stats) { |
| 61 const size_t kBufferSize = 128; | 60 const size_t kBufferSize = 128; |
| 62 char buffer[kBufferSize]; | 61 char buffer[kBufferSize]; |
| 63 | 62 |
| 64 double ms = stats.delta_.InMillisecondsF(); | 63 double ms = stats.delta_.InMillisecondsF(); |
| 65 double percent = stats.delta_.PercentOf(total_stats.delta_); | 64 double percent = stats.delta_.PercentOf(total_stats.delta_); |
| 66 double size_percent = | 65 double size_percent = |
| 67 static_cast<double>(stats.total_allocated_bytes_ * 100) / | 66 static_cast<double>(stats.total_allocated_bytes_ * 100) / |
| 68 static_cast<double>(total_stats.total_allocated_bytes_); | 67 static_cast<double>(total_stats.total_allocated_bytes_); |
| 69 base::OS::SNPrintF(buffer, kBufferSize, "%28s %10.3f (%5.1f%%) %10" PRIuS | 68 if (machine_format) { |
| 70 " (%5.1f%%) %10" PRIuS " %10" PRIuS, | 69 base::OS::SNPrintF(buffer, kBufferSize, |
| 71 name, ms, percent, stats.total_allocated_bytes_, | 70 "\"%s_time\"=%.3f\n\"%s_space\"=%" PRIuS, name, ms, name, |
| 72 size_percent, stats.max_allocated_bytes_, | 71 stats.total_allocated_bytes_); |
| 73 stats.absolute_max_allocated_bytes_); | 72 os << buffer; |
| 73 } else { | |
| 74 base::OS::SNPrintF(buffer, kBufferSize, "%28s %10.3f (%5.1f%%) %10" PRIuS | |
| 75 " (%5.1f%%) %10" PRIuS " %10" PRIuS, | |
| 76 name, ms, percent, stats.total_allocated_bytes_, | |
| 77 size_percent, stats.max_allocated_bytes_, | |
| 78 stats.absolute_max_allocated_bytes_); | |
| 74 | 79 |
| 75 os << buffer; | 80 os << buffer; |
| 76 if (stats.function_name_.size() > 0) { | 81 if (stats.function_name_.size() > 0) { |
| 77 os << " " << stats.function_name_.c_str(); | 82 os << " " << stats.function_name_.c_str(); |
| 83 } | |
| 84 os << std::endl; | |
| 78 } | 85 } |
| 79 os << std::endl; | |
| 80 } | 86 } |
| 81 | 87 |
| 82 | 88 |
| 83 static void WriteFullLine(std::ostream& os) { | 89 static void WriteFullLine(std::ostream& os) { |
| 84 os << "--------------------------------------------------------" | 90 os << "--------------------------------------------------------" |
| 85 "--------------------------------------------------------\n"; | 91 "--------------------------------------------------------\n"; |
| 86 } | 92 } |
| 87 | 93 |
| 88 | 94 |
| 89 static void WriteHeader(std::ostream& os) { | 95 static void WriteHeader(std::ostream& os) { |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 114 sorted_phase_kinds[it->second.insert_order_] = it; | 120 sorted_phase_kinds[it->second.insert_order_] = it; |
| 115 } | 121 } |
| 116 | 122 |
| 117 typedef std::vector<CompilationStatistics::PhaseMap::const_iterator> | 123 typedef std::vector<CompilationStatistics::PhaseMap::const_iterator> |
| 118 SortedPhases; | 124 SortedPhases; |
| 119 SortedPhases sorted_phases(s.phase_map_.size()); | 125 SortedPhases sorted_phases(s.phase_map_.size()); |
| 120 for (auto it = s.phase_map_.begin(); it != s.phase_map_.end(); ++it) { | 126 for (auto it = s.phase_map_.begin(); it != s.phase_map_.end(); ++it) { |
| 121 sorted_phases[it->second.insert_order_] = it; | 127 sorted_phases[it->second.insert_order_] = it; |
| 122 } | 128 } |
| 123 | 129 |
| 124 WriteHeader(os); | 130 if (!s.machine_output()) WriteHeader(os); |
|
Michael Starzinger
2016/06/13 08:22:16
This hard-codes the printing format to be exclusiv
| |
| 125 for (auto phase_kind_it : sorted_phase_kinds) { | 131 for (auto phase_kind_it : sorted_phase_kinds) { |
| 126 const auto& phase_kind_name = phase_kind_it->first; | 132 const auto& phase_kind_name = phase_kind_it->first; |
| 127 for (auto phase_it : sorted_phases) { | 133 if (!s.machine_output()) { |
| 128 const auto& phase_stats = phase_it->second; | 134 for (auto phase_it : sorted_phases) { |
| 129 if (phase_stats.phase_kind_name_ != phase_kind_name) continue; | 135 const auto& phase_stats = phase_it->second; |
| 130 const auto& phase_name = phase_it->first; | 136 if (phase_stats.phase_kind_name_ != phase_kind_name) continue; |
| 131 WriteLine(os, phase_name.c_str(), phase_stats, s.total_stats_); | 137 const auto& phase_name = phase_it->first; |
| 138 WriteLine(os, s.machine_output(), phase_name.c_str(), phase_stats, | |
| 139 s.total_stats_); | |
| 140 } | |
| 141 WritePhaseKindBreak(os); | |
| 132 } | 142 } |
| 133 WritePhaseKindBreak(os); | |
| 134 const auto& phase_kind_stats = phase_kind_it->second; | 143 const auto& phase_kind_stats = phase_kind_it->second; |
| 135 WriteLine(os, phase_kind_name.c_str(), phase_kind_stats, s.total_stats_); | 144 WriteLine(os, s.machine_output(), phase_kind_name.c_str(), phase_kind_stats, |
| 145 s.total_stats_); | |
| 136 os << std::endl; | 146 os << std::endl; |
| 137 } | 147 } |
| 138 WriteFullLine(os); | 148 |
| 139 WriteLine(os, "totals", s.total_stats_, s.total_stats_); | 149 if (!s.machine_output()) WriteFullLine(os); |
| 150 WriteLine(os, s.machine_output(), "totals", s.total_stats_, s.total_stats_); | |
| 140 | 151 |
| 141 return os; | 152 return os; |
| 142 } | 153 } |
| 143 | 154 |
| 144 } // namespace internal | 155 } // namespace internal |
| 145 } // namespace v8 | 156 } // namespace v8 |
| OLD | NEW |