summaryrefslogtreecommitdiff
path: root/simpleperf/cmd_stat_test.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2016-06-22 20:58:52 -0700
committerYabin Cui <yabinc@google.com>2016-07-06 19:09:51 -0700
commit0a45adf4bff7e6e63b17e254365c58470839d099 (patch)
treeab767ef5a0a7d4df817667d097f0e44333930408 /simpleperf/cmd_stat_test.cpp
parent90c2cd36c6284a06a5246a03c9d554a50f634f32 (diff)
downloadextras-0a45adf4bff7e6e63b17e254365c58470839d099.tar.gz
Simpleperf: add auto generated summaries in stat command.
When there are summaries monitoring one event type in user space and kernel space at the same time period, we can automatically generate a summary combining the results generated in user space and kernel space. This can help to decrease the number of needed hardware counters. Also adjust scale check when deciding whether an event is monitored all the time. Bug: 29213742 Change-Id: I272e21420700c10fccb1336a1e60138db8d13b3d Test: run simpleperf_unit_test.
Diffstat (limited to 'simpleperf/cmd_stat_test.cpp')
-rw-r--r--simpleperf/cmd_stat_test.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/simpleperf/cmd_stat_test.cpp b/simpleperf/cmd_stat_test.cpp
index 0bb7d855..4d63498a 100644
--- a/simpleperf/cmd_stat_test.cpp
+++ b/simpleperf/cmd_stat_test.cpp
@@ -16,7 +16,9 @@
#include <gtest/gtest.h>
+#include <android-base/file.h>
#include <android-base/stringprintf.h>
+#include <android-base/test_utils.h>
#include "command.h"
#include "get_test_data.h"
@@ -92,3 +94,18 @@ TEST(stat_cmd, group_option) {
"cpu-cycles:u,cpu-clock:u", "--group",
"cpu-cycles:k,cpu-clock:k", "sleep", "1"}));
}
+
+TEST(stat_cmd, auto_generated_summary) {
+ TemporaryFile tmp_file;
+ ASSERT_TRUE(StatCmd()->Run({"--group", "cpu-clock:u,cpu-clock:k", "-o",
+ tmp_file.path, "sleep", "1"}));
+ std::string s;
+ ASSERT_TRUE(android::base::ReadFileToString(tmp_file.path, &s));
+ size_t pos = s.find("cpu-clock:u");
+ ASSERT_NE(s.npos, pos);
+ pos = s.find("cpu-clock:k", pos);
+ ASSERT_NE(s.npos, pos);
+ pos += strlen("cpu-clock:k");
+ // Check if the summary of cpu-clock is generated.
+ ASSERT_NE(s.npos, s.find("cpu-clock", pos));
+}