Helper for the AggregateSummaryStats that verifies the encoded event sequence in the thrift representation when it was merged into the profile at instance offset 'offset'.
| 546 | // in the thrift representation when it was merged into the profile at instance offset |
| 547 | // 'offset'. |
| 548 | static void VerifyThriftSummaryStats( |
| 549 | const TRuntimeProfileNode& tnode, int offset, int total_instances) { |
| 550 | const int NUM_VALID_INSTANCES = 3; |
| 551 | DCHECK_LE(offset + NUM_VALID_INSTANCES, total_instances); |
| 552 | ASSERT_TRUE(tnode.__isset.aggregated); |
| 553 | |
| 554 | const TAggregatedRuntimeProfileNode& agg_node = tnode.aggregated; |
| 555 | ASSERT_TRUE(agg_node.__isset.summary_stats_counters); |
| 556 | |
| 557 | const TAggSummaryStatsCounter& tcounter = agg_node.summary_stats_counters[0]; |
| 558 | EXPECT_EQ("test ss", tcounter.name); |
| 559 | EXPECT_EQ(TUnit::UNIT, tcounter.unit); |
| 560 | |
| 561 | EXPECT_LE(offset + NUM_VALID_INSTANCES, tcounter.has_value.size()); |
| 562 | EXPECT_LE(offset + NUM_VALID_INSTANCES, tcounter.sum.size()); |
| 563 | EXPECT_LE(offset + NUM_VALID_INSTANCES, tcounter.total_num_values.size()); |
| 564 | EXPECT_LE(offset + NUM_VALID_INSTANCES, tcounter.min_value.size()); |
| 565 | EXPECT_LE(offset + NUM_VALID_INSTANCES, tcounter.max_value.size()); |
| 566 | |
| 567 | for (int i = 0; i < total_instances; ++i) { |
| 568 | if (i < offset || i >= offset + NUM_VALID_INSTANCES) { |
| 569 | EXPECT_FALSE(tcounter.has_value[i]); |
| 570 | continue; |
| 571 | } |
| 572 | EXPECT_TRUE(tcounter.has_value[i]); |
| 573 | int min_val = i - offset; |
| 574 | EXPECT_EQ(min_val * 2 + 1, tcounter.sum[i]); |
| 575 | EXPECT_EQ(2, tcounter.total_num_values[i]); |
| 576 | EXPECT_EQ(min_val, tcounter.min_value[i]); |
| 577 | EXPECT_EQ(min_val + 1, tcounter.max_value[i]); |
| 578 | } |
| 579 | } |
| 580 | |
| 581 | // Test handling of summary statistics in the aggregated profile. |
| 582 | TEST(CountersTest, AggregateSummaryStats) { |