Chromium Code Reviews| Index: src/compilation-statistics.cc |
| diff --git a/src/compilation-statistics.cc b/src/compilation-statistics.cc |
| index c7e15b230b2fa7527c04d417b568483e068fcbe8..d0317aacb4cb7c2ad46ed3fe38b909e8feb53575 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; |
| } |
| @@ -121,22 +127,27 @@ std::ostream& operator<<(std::ostream& os, const CompilationStatistics& s) { |
| sorted_phases[it->second.insert_order_] = it; |
| } |
| - WriteHeader(os); |
| + if (!s.machine_output()) WriteHeader(os); |
|
Michael Starzinger
2016/06/13 08:22:16
This hard-codes the printing format to be exclusiv
|
| 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 (!s.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, s.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, s.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 (!s.machine_output()) WriteFullLine(os); |
| + WriteLine(os, s.machine_output(), "totals", s.total_stats_, s.total_stats_); |
| return os; |
| } |