diff options
author | Yabin Cui <yabinc@google.com> | 2017-05-02 13:25:21 -0700 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2017-05-02 15:06:25 -0700 |
commit | 07ee9416bcaf6b1e2da2fadbc73995d27dbebb42 (patch) | |
tree | 1605708e9c7976f93b1f3d2b21a9af424435e657 | |
parent | 8bc6d740bd130f2c05b492edfd76f879a6f443fd (diff) | |
download | extras-07ee9416bcaf6b1e2da2fadbc73995d27dbebb42.tar.gz |
simpleperf: add 'event_count' field in report proto.
Bug: http://b/37294023
Test: run simpleperf_unit_test.
Change-Id: Ib16eec55512769a9a241c8ff054179d450488142
-rw-r--r-- | simpleperf/cmd_report_sample.cpp | 3 | ||||
-rw-r--r-- | simpleperf/cmd_report_sample_test.cpp | 12 | ||||
-rw-r--r-- | simpleperf/report_sample.proto | 9 |
3 files changed, 24 insertions, 0 deletions
diff --git a/simpleperf/cmd_report_sample.cpp b/simpleperf/cmd_report_sample.cpp index 24d1bc0d..e28ea3b4 100644 --- a/simpleperf/cmd_report_sample.cpp +++ b/simpleperf/cmd_report_sample.cpp @@ -274,6 +274,7 @@ bool ReportSampleCommand::DumpProtobufReport(const std::string& filename) { static size_t sample_count = 0; FprintIndented(report_fp_, 0, "sample %zu:\n", ++sample_count); FprintIndented(report_fp_, 1, "time: %" PRIu64 "\n", sample.time()); + FprintIndented(report_fp_, 1, "event_count: %" PRIu64 "\n", sample.event_count()); FprintIndented(report_fp_, 1, "thread_id: %d\n", sample.thread_id()); FprintIndented(report_fp_, 1, "callchain:\n"); for (int i = 0; i < sample.callchain_size(); ++i) { @@ -357,6 +358,7 @@ bool ReportSampleCommand::PrintSampleRecordInProtobuf(const SampleRecord& r) { proto::Record proto_record; proto::Sample* sample = proto_record.mutable_sample(); sample->set_time(r.time_data.time); + sample->set_event_count(r.period_data.period); sample->set_thread_id(r.tid_data.tid); bool in_kernel = r.InKernel(); @@ -516,6 +518,7 @@ bool ReportSampleCommand::PrintSampleRecord(const SampleRecord& r) { FprintIndented(report_fp_, 0, "sample:\n"); FprintIndented(report_fp_, 1, "time: %" PRIu64 "\n", r.time_data.time); + FprintIndented(report_fp_, 1, "event_count: %" PRIu64 "\n", r.period_data.period); FprintIndented(report_fp_, 1, "thread_id: %d\n", r.tid_data.tid); bool in_kernel = r.InKernel(); const ThreadEntry* thread = diff --git a/simpleperf/cmd_report_sample_test.cpp b/simpleperf/cmd_report_sample_test.cpp index 81d90988..3e92396d 100644 --- a/simpleperf/cmd_report_sample_test.cpp +++ b/simpleperf/cmd_report_sample_test.cpp @@ -67,3 +67,15 @@ TEST(cmd_report_sample, no_skipped_file_id) { ASSERT_TRUE(android::base::ReadFileToString(tmpfile2.path, &data)); ASSERT_EQ(data.find("unknown"), std::string::npos); } + +TEST(cmd_report_sample, sample_has_event_count) { + TemporaryFile tmpfile; + TemporaryFile tmpfile2; + ASSERT_TRUE(ReportSampleCmd()->Run({"-i", GetTestData(PERF_DATA_WITH_SYMBOLS), + "-o", tmpfile.path, "--protobuf"})); + ASSERT_TRUE(ReportSampleCmd()->Run( + {"--dump-protobuf-report", tmpfile.path, "-o", tmpfile2.path})); + std::string data; + ASSERT_TRUE(android::base::ReadFileToString(tmpfile2.path, &data)); + ASSERT_NE(data.find("event_count:"), std::string::npos); +} diff --git a/simpleperf/report_sample.proto b/simpleperf/report_sample.proto index c591aba3..5e1d8605 100644 --- a/simpleperf/report_sample.proto +++ b/simpleperf/report_sample.proto @@ -15,6 +15,8 @@ option java_package = "com.android.tools.profiler.proto"; option java_outer_classname = "SimpleperfReport"; message Sample { + // Wall clock time for current sample. + // By default, it is perf clock used in kernel. optional uint64 time = 1; optional int32 thread_id = 2; @@ -32,6 +34,13 @@ message Sample { } repeated CallChainEntry callchain = 3; + + // Count of the events that have happened since last sample (regardless of + // whether the last sample is lost). The event type is decided by '-e' option + // in simpleperf record command. By default, '-e cpu-cycles' is used, and this + // field is the number of cpu cycles. + optional uint64 event_count = 4; + } message LostSituation { |