diff options
author | Wei Wang <wvw@google.com> | 2016-09-28 14:42:02 -0700 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2016-09-29 14:50:34 -0700 |
commit | 539fb885d08f5cdb11b409de776ec567b1bfcc29 (patch) | |
tree | d53d33584e27ae7cb2c37c5d79399a3d9da2ac34 /simpleperf/cmd_stat_test.cpp | |
parent | 1a35848b34d6572a6b65fe50133414b2dcbea92b (diff) | |
download | extras-539fb885d08f5cdb11b409de776ec567b1bfcc29.tar.gz |
simpleperf: add interval to stat print
Add a stat interval printing
Bug: http://b/31806433
Test: simpleperf_unit_test --gtest_filter=stat_cmd.interval_option
Change-Id: Ia2881d990036cc099baccb8a2d8cd3828877a910
(cherry picked from commit e6d8a52400fe710b743ce57b89bd015ab219434b)
Diffstat (limited to 'simpleperf/cmd_stat_test.cpp')
-rw-r--r-- | simpleperf/cmd_stat_test.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/simpleperf/cmd_stat_test.cpp b/simpleperf/cmd_stat_test.cpp index 5748b7a7..25fcaf99 100644 --- a/simpleperf/cmd_stat_test.cpp +++ b/simpleperf/cmd_stat_test.cpp @@ -85,7 +85,7 @@ TEST(stat_cmd, no_monitored_threads) { ASSERT_FALSE(StatCmd()->Run({""})); } TEST(stat_cmd, group_option) { ASSERT_TRUE( - StatCmd()->Run({"--group", "cpu-cycles,cpu-clock", "sleep", "1"})); + StatCmd()->Run({"--group", "cpu-clock,page-faults", "sleep", "1"})); ASSERT_TRUE(StatCmd()->Run({"--group", "cpu-cycles,instructions", "--group", "cpu-cycles:u,instructions:u", "--group", "cpu-cycles:k,instructions:k", "sleep", "1"})); @@ -112,6 +112,23 @@ TEST(stat_cmd, duration_option) { ASSERT_TRUE(StatCmd()->Run({"--duration", "1", "sleep", "2"})); } +TEST(stat_cmd, interval_option) { + TemporaryFile tmp_file; + ASSERT_TRUE( + StatCmd()->Run({"--interval", "500.0", "--duration", "1.2", "-o", + tmp_file.path, "sleep", "2"})); + std::string s; + ASSERT_TRUE(android::base::ReadFileToString(tmp_file.path, &s)); + size_t count = 0; + size_t pos = 0; + std::string subs = "statistics:"; + while((pos = s.find(subs, pos)) != s.npos) { + pos += subs.size(); + ++count ; + } + ASSERT_EQ(count, 3UL); +} + TEST(stat_cmd, no_modifier_for_clock_events) { for (const std::string& e : {"cpu-clock", "task-clock"}) { for (const std::string& m : {"u", "k"}) { |