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. |