| 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;
|
| }
|
|
|