summaryrefslogtreecommitdiff
path: root/simpleperf/cmd_stat_impl.h
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2020-03-31 16:59:33 -0700
committerYabin Cui <yabinc@google.com>2020-04-01 01:02:37 -0700
commit5271aa719b7cae4cddc9f67803648f17f9b24018 (patch)
treeb7bde87155f04b04b8784c42b83242d61da8e399 /simpleperf/cmd_stat_impl.h
parent7df4d3a9f405d5354669391cbc7b24f471667112 (diff)
downloadextras-5271aa719b7cae4cddc9f67803648f17f9b24018.tar.gz
simpleperf: move CounterSummaries definition to header file.
This is to test it in later CLs. Bug: 152911261 Test: run simpleperf_unit_test. Change-Id: I0cdad299654eb36db4a64363335bfa03e54ee7b1
Diffstat (limited to 'simpleperf/cmd_stat_impl.h')
-rw-r--r--simpleperf/cmd_stat_impl.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/simpleperf/cmd_stat_impl.h b/simpleperf/cmd_stat_impl.h
index 16dd091d..f8a751fe 100644
--- a/simpleperf/cmd_stat_impl.h
+++ b/simpleperf/cmd_stat_impl.h
@@ -243,4 +243,34 @@ class CounterSummaryBuilder {
std::vector<CounterSummary> summaries_;
};
+class CounterSummaries {
+ public:
+ explicit CounterSummaries(std::vector<CounterSummary>&& summaries, bool csv)
+ : summaries_(std::move(summaries)), csv_(csv) {}
+ const std::vector<CounterSummary>& Summaries() { return summaries_; }
+
+ const CounterSummary* FindSummary(const std::string& type_name, const std::string& modifier,
+ const ThreadInfo* thread, int cpu);
+
+ // If we have two summaries monitoring the same event type at the same time,
+ // that one is for user space only, and the other is for kernel space only;
+ // then we can automatically generate a summary combining the two results.
+ // For example, a summary of branch-misses:u and a summary for branch-misses:k
+ // can generate a summary of branch-misses.
+ void AutoGenerateSummaries();
+ void GenerateComments(double duration_in_sec);
+ void Show(FILE* fp);
+ void ShowCSV(FILE* fp);
+ void ShowText(FILE* fp);
+
+ private:
+ std::string GetCommentForSummary(const CounterSummary& s, double duration_in_sec);
+ std::string GetRateComment(const CounterSummary& s, char sep);
+ bool FindRunningTimeForSummary(const CounterSummary& summary, double* running_time_in_sec);
+
+ private:
+ std::vector<CounterSummary> summaries_;
+ bool csv_;
+};
+
} // namespace simpleperf \ No newline at end of file