Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(721)

Side by Side Diff: src/compilation-statistics.cc

Issue 2053383002: Machine-readable TurboFan compiler statistics (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Code comments. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compilation-statistics.h ('k') | src/compiler/pipeline.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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) {
90 WriteFullLine(os); 96 WriteFullLine(os);
91 os << " Turbonfan phase Time (ms) " 97 os << " Turbonfan phase Time (ms) "
92 << " Space (bytes) Function\n" 98 << " Space (bytes) Function\n"
93 << " " 99 << " "
94 << " Total Max. Abs. max.\n"; 100 << " Total Max. Abs. max.\n";
95 WriteFullLine(os); 101 WriteFullLine(os);
96 } 102 }
97 103
98 104
99 static void WritePhaseKindBreak(std::ostream& os) { 105 static void WritePhaseKindBreak(std::ostream& os) {
100 os << " ---------------------------" 106 os << " ---------------------------"
101 "--------------------------------------------------------\n"; 107 "--------------------------------------------------------\n";
102 } 108 }
103 109
104 110 std::ostream& operator<<(std::ostream& os, const AsPrintableStatistics& ps) {
105 std::ostream& operator<<(std::ostream& os, const CompilationStatistics& s) {
106 // phase_kind_map_ and phase_map_ don't get mutated, so store a bunch of 111 // phase_kind_map_ and phase_map_ don't get mutated, so store a bunch of
107 // pointers into them. 112 // pointers into them.
113 const CompilationStatistics& s = ps.s;
108 114
109 typedef std::vector<CompilationStatistics::PhaseKindMap::const_iterator> 115 typedef std::vector<CompilationStatistics::PhaseKindMap::const_iterator>
110 SortedPhaseKinds; 116 SortedPhaseKinds;
111 SortedPhaseKinds sorted_phase_kinds(s.phase_kind_map_.size()); 117 SortedPhaseKinds sorted_phase_kinds(s.phase_kind_map_.size());
112 for (auto it = s.phase_kind_map_.begin(); it != s.phase_kind_map_.end(); 118 for (auto it = s.phase_kind_map_.begin(); it != s.phase_kind_map_.end();
113 ++it) { 119 ++it) {
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 (!ps.machine_output) WriteHeader(os);
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 (!ps.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, ps.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, ps.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 (!ps.machine_output) WriteFullLine(os);
150 WriteLine(os, ps.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
OLDNEW
« no previous file with comments | « src/compilation-statistics.h ('k') | src/compiler/pipeline.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698