summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2017-02-24 02:06:40 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-02-24 02:06:40 +0000
commit8a5738658e4b6d7f3331013929c75efcb7809dad (patch)
tree876a98359c0fc75ff18a220060ac9b5cc3d76b16
parentafb397b6b254996ef4a6bed1c978ab6c3d6057c9 (diff)
parentb5454fcd35a2af7732e023acb5e63f807627170f (diff)
downloadextras-8a5738658e4b6d7f3331013929c75efcb7809dad.tar.gz
Merge "simpleperf: add --raw-period option for report cmd." am: d0d21b88ce am: 7db7e63529
am: b5454fcd35 Change-Id: I19ea2ac84f402d890573f89ac3bd69aa93e56d97
-rw-r--r--simpleperf/SampleDisplayer.h6
-rw-r--r--simpleperf/cmd_report.cpp23
-rw-r--r--simpleperf/cmd_report_test.cpp7
3 files changed, 31 insertions, 5 deletions
diff --git a/simpleperf/SampleDisplayer.h b/simpleperf/SampleDisplayer.h
index 7904ef85..4317582a 100644
--- a/simpleperf/SampleDisplayer.h
+++ b/simpleperf/SampleDisplayer.h
@@ -36,6 +36,11 @@ std::string DisplayAccumulatedOverhead(const EntryT* sample,
return android::base::StringPrintf("%.2f%%", percentage);
}
+template <typename EntryT>
+std::string DisplayAccumulatedPeriod(const EntryT* sample) {
+ return android::base::StringPrintf("%" PRIu64, sample->period + sample->accumulated_period);
+}
+
template <typename EntryT, typename InfoT>
std::string DisplaySelfOverhead(const EntryT* sample, const InfoT* info) {
uint64_t period = sample->period;
@@ -56,6 +61,7 @@ std::string DisplaySelfOverhead(const EntryT* sample, const InfoT* info) {
return android::base::StringPrintf("0x%" PRIx64, sample->display_part); \
}
+BUILD_DISPLAY_UINT64_FUNCTION(DisplaySelfPeriod, period);
BUILD_DISPLAY_UINT64_FUNCTION(DisplaySampleCount, sample_count);
template <typename EntryT>
diff --git a/simpleperf/cmd_report.cpp b/simpleperf/cmd_report.cpp
index 3b727a5e..883b983b 100644
--- a/simpleperf/cmd_report.cpp
+++ b/simpleperf/cmd_report.cpp
@@ -291,6 +291,7 @@ class ReportCommand : public Command {
"-o report_file_name Set report file name, default is stdout.\n"
"--percent-limit <percent> Set min percentage shown when printing call graph.\n"
"--pids pid1,pid2,... Report only for selected pids.\n"
+"--raw-period Report period count instead of period percentage.\n"
"--sort key1,key2,... Select keys used to sort and print the report. The\n"
" appearance order of keys decides the order of keys used\n"
" to sort and print the report.\n"
@@ -324,7 +325,8 @@ class ReportCommand : public Command {
print_callgraph_(false),
callgraph_show_callee_(false),
callgraph_max_stack_(UINT32_MAX),
- callgraph_percent_limit_(0) {}
+ callgraph_percent_limit_(0),
+ raw_period_(false) {}
bool Run(const std::vector<std::string>& args);
@@ -355,6 +357,7 @@ class ReportCommand : public Command {
bool callgraph_show_callee_;
uint32_t callgraph_max_stack_;
double callgraph_percent_limit_;
+ bool raw_period_;
std::string report_filename_;
};
@@ -491,7 +494,8 @@ bool ReportCommand::ParseOptions(const std::vector<std::string>& args) {
}
filter.insert(id);
}
-
+ } else if (args[i] == "--raw-period") {
+ raw_period_ = true;
} else if (args[i] == "--sort") {
if (!NextArgumentOrError(args, &i)) {
return false;
@@ -536,10 +540,19 @@ bool ReportCommand::ParseOptions(const std::vector<std::string>& args) {
SampleComparator<SampleEntry> comparator;
if (accumulate_callchain_) {
- displayer.AddDisplayFunction("Children", DisplayAccumulatedOverhead);
- displayer.AddDisplayFunction("Self", DisplaySelfOverhead);
+ if (raw_period_) {
+ displayer.AddDisplayFunction("Children", DisplayAccumulatedPeriod);
+ displayer.AddDisplayFunction("Self", DisplaySelfPeriod);
+ } else {
+ displayer.AddDisplayFunction("Children", DisplayAccumulatedOverhead);
+ displayer.AddDisplayFunction("Self", DisplaySelfOverhead);
+ }
} else {
- displayer.AddDisplayFunction("Overhead", DisplaySelfOverhead);
+ if (raw_period_) {
+ displayer.AddDisplayFunction("Overhead", DisplaySelfPeriod);
+ } else {
+ displayer.AddDisplayFunction("Overhead", DisplaySelfOverhead);
+ }
}
if (print_sample_count) {
displayer.AddDisplayFunction("Sample", DisplaySampleCount);
diff --git a/simpleperf/cmd_report_test.cpp b/simpleperf/cmd_report_test.cpp
index 9a5c23bd..7dcee4f4 100644
--- a/simpleperf/cmd_report_test.cpp
+++ b/simpleperf/cmd_report_test.cpp
@@ -454,6 +454,13 @@ TEST_F(ReportCommandTest, invalid_perf_data) {
ASSERT_FALSE(ReportCmd()->Run({"-i", GetTestData(INVALID_PERF_DATA)}));
}
+TEST_F(ReportCommandTest, raw_period_option) {
+ Report(PERF_DATA, {"--raw-period"});
+ ASSERT_TRUE(success);
+ ASSERT_NE(content.find("GlobalFunc"), std::string::npos);
+ ASSERT_EQ(content.find("%"), std::string::npos);
+}
+
#if defined(__linux__)
#include "event_selection_set.h"