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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compilation-statistics.h ('k') | src/compiler/pipeline.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compilation-statistics.cc
diff --git a/src/compilation-statistics.cc b/src/compilation-statistics.cc
index c7e15b230b2fa7527c04d417b568483e068fcbe8..d4ca39d6112a53ba2298d2fe626696d080cbf961 100644
--- a/src/compilation-statistics.cc
+++ b/src/compilation-statistics.cc
@@ -54,8 +54,7 @@ void CompilationStatistics::BasicStats::Accumulate(const BasicStats& stats) {
}
}
-
-static void WriteLine(std::ostream& os, const char* name,
+static void WriteLine(std::ostream& os, bool machine_format, const char* name,
const CompilationStatistics::BasicStats& stats,
const CompilationStatistics::BasicStats& total_stats) {
const size_t kBufferSize = 128;
@@ -66,17 +65,24 @@ static void WriteLine(std::ostream& os, const char* name,
double size_percent =
static_cast<double>(stats.total_allocated_bytes_ * 100) /
static_cast<double>(total_stats.total_allocated_bytes_);
- base::OS::SNPrintF(buffer, kBufferSize, "%28s %10.3f (%5.1f%%) %10" PRIuS
- " (%5.1f%%) %10" PRIuS " %10" PRIuS,
- name, ms, percent, stats.total_allocated_bytes_,
- size_percent, stats.max_allocated_bytes_,
- stats.absolute_max_allocated_bytes_);
-
- os << buffer;
- if (stats.function_name_.size() > 0) {
- os << " " << stats.function_name_.c_str();
+ if (machine_format) {
+ base::OS::SNPrintF(buffer, kBufferSize,
+ "\"%s_time\"=%.3f\n\"%s_space\"=%" PRIuS, name, ms, name,
+ stats.total_allocated_bytes_);
+ os << buffer;
+ } else {
+ base::OS::SNPrintF(buffer, kBufferSize, "%28s %10.3f (%5.1f%%) %10" PRIuS
+ " (%5.1f%%) %10" PRIuS " %10" PRIuS,
+ name, ms, percent, stats.total_allocated_bytes_,
+ size_percent, stats.max_allocated_bytes_,
+ stats.absolute_max_allocated_bytes_);
+
+ os << buffer;
+ if (stats.function_name_.size() > 0) {
+ os << " " << stats.function_name_.c_str();
+ }
+ os << std::endl;
}
- os << std::endl;
}
@@ -101,10 +107,10 @@ static void WritePhaseKindBreak(std::ostream& os) {
"--------------------------------------------------------\n";
}
-
-std::ostream& operator<<(std::ostream& os, const CompilationStatistics& s) {
+std::ostream& operator<<(std::ostream& os, const AsPrintableStatistics& ps) {
// phase_kind_map_ and phase_map_ don't get mutated, so store a bunch of
// pointers into them.
+ const CompilationStatistics& s = ps.s;
typedef std::vector<CompilationStatistics::PhaseKindMap::const_iterator>
SortedPhaseKinds;
@@ -121,22 +127,27 @@ std::ostream& operator<<(std::ostream& os, const CompilationStatistics& s) {
sorted_phases[it->second.insert_order_] = it;
}
- WriteHeader(os);
+ if (!ps.machine_output) WriteHeader(os);
for (auto phase_kind_it : sorted_phase_kinds) {
const auto& phase_kind_name = phase_kind_it->first;
- for (auto phase_it : sorted_phases) {
- const auto& phase_stats = phase_it->second;
- if (phase_stats.phase_kind_name_ != phase_kind_name) continue;
- const auto& phase_name = phase_it->first;
- WriteLine(os, phase_name.c_str(), phase_stats, s.total_stats_);
+ if (!ps.machine_output) {
+ for (auto phase_it : sorted_phases) {
+ const auto& phase_stats = phase_it->second;
+ if (phase_stats.phase_kind_name_ != phase_kind_name) continue;
+ const auto& phase_name = phase_it->first;
+ WriteLine(os, ps.machine_output, phase_name.c_str(), phase_stats,
+ s.total_stats_);
+ }
+ WritePhaseKindBreak(os);
}
- WritePhaseKindBreak(os);
const auto& phase_kind_stats = phase_kind_it->second;
- WriteLine(os, phase_kind_name.c_str(), phase_kind_stats, s.total_stats_);
+ WriteLine(os, ps.machine_output, phase_kind_name.c_str(), phase_kind_stats,
+ s.total_stats_);
os << std::endl;
}
- WriteFullLine(os);
- WriteLine(os, "totals", s.total_stats_, s.total_stats_);
+
+ if (!ps.machine_output) WriteFullLine(os);
+ WriteLine(os, ps.machine_output, "totals", s.total_stats_, s.total_stats_);
return os;
}
« 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