summaryrefslogtreecommitdiff
path: root/simpleperf
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2017-05-03 00:21:40 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-05-03 00:21:40 +0000
commit9ba61e5af1fdaa23192018589c2996671d3ff079 (patch)
tree9e141b8395355f2e5e7777b0d914cdf53d7d1b52 /simpleperf
parentf066c6b2bc4c567b74d96903bad5f9cab6a92f77 (diff)
parentc6b0cf2cf39b936ffbebc8c16640fcf7ea46d0ff (diff)
downloadextras-9ba61e5af1fdaa23192018589c2996671d3ff079.tar.gz
Merge "simpleperf: add 'event_count' field in report proto." am: 7d8e85589c am: e848471461
am: c6b0cf2cf3 Change-Id: I4ad8d12950cb094d448a9ea3581c32e622297546
Diffstat (limited to 'simpleperf')
-rw-r--r--simpleperf/cmd_report_sample.cpp3
-rw-r--r--simpleperf/cmd_report_sample_test.cpp12
-rw-r--r--simpleperf/report_sample.proto9
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 {