Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(662)

Unified Diff: base/test/trace_event_analyzer_unittest.cc

Issue 9580021: Add test for RAF-spinning with no damage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: marking test flaky for initial commit to be safe Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/test/trace_event_analyzer.cc ('k') | chrome/test/data/gpu/feature_raf_no_damage.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/trace_event_analyzer_unittest.cc
diff --git a/base/test/trace_event_analyzer_unittest.cc b/base/test/trace_event_analyzer_unittest.cc
index e533c4932a7493760de36fd484a176189b27ed2c..55309db12216ac1bebd4530b98f1f422f942e9f3 100644
--- a/base/test/trace_event_analyzer_unittest.cc
+++ b/base/test/trace_event_analyzer_unittest.cc
@@ -644,36 +644,69 @@ TEST_F(TraceEventAnalyzerTest, RateStats) {
event.timestamp = 0.0;
double little_delta = 1.0;
double big_delta = 10.0;
+ double tiny_delta = 0.1;
RateStats stats;
+ RateStatsOptions options;
+ // Insert 10 events, each apart by little_delta.
for (int i = 0; i < 10; ++i) {
event.timestamp += little_delta;
events.push_back(event);
event_ptrs.push_back(&events.back());
}
- ASSERT_TRUE(GetRateStats(event_ptrs, &stats));
+ ASSERT_TRUE(GetRateStats(event_ptrs, &stats, NULL));
EXPECT_EQ(little_delta, stats.mean_us);
EXPECT_EQ(little_delta, stats.min_us);
EXPECT_EQ(little_delta, stats.max_us);
EXPECT_EQ(0.0, stats.standard_deviation_us);
+ // Add an event apart by big_delta.
event.timestamp += big_delta;
events.push_back(event);
event_ptrs.push_back(&events.back());
- ASSERT_TRUE(GetRateStats(event_ptrs, &stats));
+ ASSERT_TRUE(GetRateStats(event_ptrs, &stats, NULL));
EXPECT_LT(little_delta, stats.mean_us);
EXPECT_EQ(little_delta, stats.min_us);
EXPECT_EQ(big_delta, stats.max_us);
EXPECT_LT(0.0, stats.standard_deviation_us);
+ // Trim off the biggest delta and verify stats.
+ options.trim_min = 0;
+ options.trim_max = 1;
+ ASSERT_TRUE(GetRateStats(event_ptrs, &stats, &options));
+ EXPECT_EQ(little_delta, stats.mean_us);
+ EXPECT_EQ(little_delta, stats.min_us);
+ EXPECT_EQ(little_delta, stats.max_us);
+ EXPECT_EQ(0.0, stats.standard_deviation_us);
+
+ // Add an event apart by tiny_delta.
+ event.timestamp += tiny_delta;
+ events.push_back(event);
+ event_ptrs.push_back(&events.back());
+
+ // Trim off both the biggest and tiniest delta and verify stats.
+ options.trim_min = 1;
+ options.trim_max = 1;
+ ASSERT_TRUE(GetRateStats(event_ptrs, &stats, &options));
+ EXPECT_EQ(little_delta, stats.mean_us);
+ EXPECT_EQ(little_delta, stats.min_us);
+ EXPECT_EQ(little_delta, stats.max_us);
+ EXPECT_EQ(0.0, stats.standard_deviation_us);
+
+ // Verify smallest allowed number of events.
TraceEventVector few_event_ptrs;
few_event_ptrs.push_back(&event);
few_event_ptrs.push_back(&event);
- ASSERT_FALSE(GetRateStats(few_event_ptrs, &stats));
+ ASSERT_FALSE(GetRateStats(few_event_ptrs, &stats, NULL));
few_event_ptrs.push_back(&event);
- ASSERT_TRUE(GetRateStats(few_event_ptrs, &stats));
+ ASSERT_TRUE(GetRateStats(few_event_ptrs, &stats, NULL));
+
+ // Trim off more than allowed and verify failure.
+ options.trim_min = 0;
+ options.trim_max = 1;
+ ASSERT_FALSE(GetRateStats(few_event_ptrs, &stats, &options));
}
// Test FindFirstOf and FindLastOf.
« no previous file with comments | « base/test/trace_event_analyzer.cc ('k') | chrome/test/data/gpu/feature_raf_no_damage.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698