diff options
| author | android-build-team Robot <android-build-team-robot@google.com> | 2018-02-05 08:21:56 +0000 |
|---|---|---|
| committer | android-build-team Robot <android-build-team-robot@google.com> | 2018-02-05 08:21:56 +0000 |
| commit | 8167805987d65fc5dd9b24b8f69fef962a941c61 (patch) | |
| tree | abb8195b75a68b4d402374d9a33538907b948837 | |
| parent | d0e4c5d89abfd637b13a6f0324b96a071d313098 (diff) | |
| parent | 0cb976c71838c6c6bbe6710e29f641082c62e4c8 (diff) | |
| download | platform_build_kati-8167805987d65fc5dd9b24b8f69fef962a941c61.tar.gz platform_build_kati-8167805987d65fc5dd9b24b8f69fef962a941c61.tar.bz2 platform_build_kati-8167805987d65fc5dd9b24b8f69fef962a941c61.zip | |
Snap for 4585119 from 0cb976c71838c6c6bbe6710e29f641082c62e4c8 to pi-release
Change-Id: I937c56b45648fb80368eaa7415233b8c955c4f0f
| -rw-r--r-- | find.cc | 6 | ||||
| -rw-r--r-- | stats.cc | 24 | ||||
| -rw-r--r-- | stats.h | 5 |
3 files changed, 30 insertions, 5 deletions
@@ -733,7 +733,8 @@ class FindCommandParser { if (!GetNextToken(&tok) || !tok.empty()) return false; return true; - } else if (tok == "build/tools/findleaves.py") { + } else if (tok == "build/tools/findleaves.py" || + tok == "build/make/tools/findleaves.py") { if (!ParseFindLeaves()) return false; return true; @@ -1033,7 +1034,8 @@ FindCommand::~FindCommand() {} bool FindCommand::Parse(const string& cmd) { FindCommandParser fcp(cmd, this); - if (!HasWord(cmd, "find") && !HasWord(cmd, "build/tools/findleaves.py")) + if (!HasWord(cmd, "find") && !HasWord(cmd, "build/tools/findleaves.py") && + !HasWord(cmd, "build/make/tools/findleaves.py")) return false; if (!fcp.Parse()) @@ -16,6 +16,7 @@ #include "stats.h" +#include <algorithm> #include <mutex> #include <vector> @@ -40,6 +41,21 @@ Stats::Stats(const char* name) : name_(name), elapsed_(0), cnt_(0) { g_stats->push_back(this); } +void Stats::DumpTop() const { + unique_lock<mutex> lock(mu_); + if (detailed_.size() > 0) { + vector<pair<string, double>> v(detailed_.begin(), detailed_.end()); + sort( + v.begin(), v.end(), + [](const pair<string, double> a, const pair<string, double> b) -> bool { + return a.second > b.second; + }); + for (unsigned int i = 0; i < 10 && i < v.size(); i++) { + LOG_STAT(" %5.3f %s", v[i].first.c_str(), v[i].second); + } + } +} + string Stats::String() const { unique_lock<mutex> lock(mu_); return StringPrintf("%s: %f / %d", name_, elapsed_, cnt_); @@ -52,12 +68,15 @@ void Stats::Start() { cnt_++; } -double Stats::End() { +double Stats::End(const char* msg) { CHECK(TLS_REF(g_start_time)); double e = GetTime() - TLS_REF(g_start_time); TLS_REF(g_start_time) = 0; unique_lock<mutex> lock(mu_); elapsed_ += e; + if (msg != 0) { + detailed_[string(msg)] += e; + } return e; } @@ -71,7 +90,7 @@ ScopedStatsRecorder::ScopedStatsRecorder(Stats* st, const char* msg) ScopedStatsRecorder::~ScopedStatsRecorder() { if (!g_flags.enable_stat_logs) return; - double e = st_->End(); + double e = st_->End(msg_); if (msg_ && e > 3.0) { LOG_STAT("slow %s (%f): %s", st_->name_, e, msg_); } @@ -82,6 +101,7 @@ void ReportAllStats() { return; for (Stats* st : *g_stats) { LOG_STAT("%s", st->String().c_str()); + st->DumpTop(); } delete g_stats; } @@ -17,6 +17,7 @@ #include <mutex> #include <string> +#include <unordered_map> using namespace std; @@ -24,11 +25,12 @@ class Stats { public: explicit Stats(const char* name); + void DumpTop() const; string String() const; private: void Start(); - double End(); + double End(const char* msg); friend class ScopedStatsRecorder; @@ -36,6 +38,7 @@ class Stats { double elapsed_; int cnt_; mutable mutex mu_; + unordered_map<string, double> detailed_; }; class ScopedStatsRecorder { |
