diff options
author | Yabin Cui <yabinc@google.com> | 2017-02-23 16:27:09 -0800 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2017-02-23 16:27:09 -0800 |
commit | afe99a53d3030f54fa843af3e1558852a4cb3815 (patch) | |
tree | ef9c6bb5583edeb2b948a879e835ad6cd39da217 | |
parent | d9d23181768df567d166b79a89cfc0408e086509 (diff) | |
download | extras-afe99a53d3030f54fa843af3e1558852a4cb3815.tar.gz |
simpleperf: add --raw-period option for report cmd.
Bug: http://b/35475170
Test: run simpleperf_unit_test.
Change-Id: Ib5bae0b775ac2a3e647b7724df01ce0b8deb1a38
-rw-r--r-- | simpleperf/SampleDisplayer.h | 6 | ||||
-rw-r--r-- | simpleperf/cmd_report.cpp | 23 | ||||
-rw-r--r-- | simpleperf/cmd_report_test.cpp | 7 |
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" |