Helper for the AggregateEventSequences that verifies the encoded event sequence in the thrift representation when it was merged into the profile at instance offset 'offset'.
| 971 | // in the thrift representation when it was merged into the profile at instance offset |
| 972 | // 'offset'. |
| 973 | static void VerifyThriftEventSequences( |
| 974 | const TRuntimeProfileNode& tnode, int offset, int total_instances) { |
| 975 | ASSERT_TRUE(tnode.__isset.aggregated); |
| 976 | const int NUM_VALID_INSTANCES = 3; |
| 977 | DCHECK_LE(offset + NUM_VALID_INSTANCES, total_instances); |
| 978 | |
| 979 | const TAggregatedRuntimeProfileNode& agg_node = tnode.aggregated; |
| 980 | ASSERT_TRUE(agg_node.__isset.event_sequences); |
| 981 | ASSERT_EQ(1, agg_node.event_sequences.size()); |
| 982 | // Check that the dictionary encoding worked. |
| 983 | const TAggEventSequence& tseq = agg_node.event_sequences[0]; |
| 984 | EXPECT_EQ("event sequence", tseq.name); |
| 985 | EXPECT_EQ("aaaa", tseq.label_dict[0]); |
| 986 | EXPECT_EQ("bbbb", tseq.label_dict[1]); |
| 987 | EXPECT_EQ("cccc", tseq.label_dict[2]); |
| 988 | EXPECT_EQ("dddd", tseq.label_dict[3]); |
| 989 | |
| 990 | // Validate that the right number of instances are present and that the invalid |
| 991 | // instances do not have any data associated with them. |
| 992 | EXPECT_EQ(total_instances, tseq.label_idxs.size()); |
| 993 | EXPECT_EQ(total_instances, tseq.timestamps.size()); |
| 994 | for (int i = 0; i < total_instances; ++i) { |
| 995 | if (i < offset || i >= offset + NUM_VALID_INSTANCES) { |
| 996 | EXPECT_EQ(0, tseq.label_idxs[i].size()); |
| 997 | EXPECT_EQ(0, tseq.timestamps[i].size()); |
| 998 | } |
| 999 | } |
| 1000 | |
| 1001 | // Validate the label/timestamp values for the valid instances. |
| 1002 | EXPECT_EQ(3, tseq.label_idxs[offset + 0].size()); |
| 1003 | EXPECT_EQ(0, tseq.label_idxs[offset + 0][0]); |
| 1004 | EXPECT_EQ(1, tseq.label_idxs[offset + 0][1]); |
| 1005 | EXPECT_EQ(2, tseq.label_idxs[offset + 0][2]); |
| 1006 | EXPECT_EQ(3, tseq.timestamps[offset + 0].size()); |
| 1007 | CheckAscending(tseq.timestamps[offset + 0]); |
| 1008 | |
| 1009 | EXPECT_EQ(2, tseq.label_idxs[offset + 1].size()); |
| 1010 | EXPECT_EQ(0, tseq.label_idxs[offset + 1][0]); |
| 1011 | EXPECT_EQ(2, tseq.label_idxs[offset + 1][1]); |
| 1012 | EXPECT_EQ(2, tseq.timestamps[offset + 1].size()); |
| 1013 | CheckAscending(tseq.timestamps[offset + 1]); |
| 1014 | |
| 1015 | EXPECT_EQ(3, tseq.label_idxs[offset + 2].size()); |
| 1016 | EXPECT_EQ(0, tseq.label_idxs[offset + 2][0]); |
| 1017 | EXPECT_EQ(3, tseq.label_idxs[offset + 2][1]); |
| 1018 | EXPECT_EQ(1, tseq.label_idxs[offset + 2][2]); |
| 1019 | EXPECT_EQ(3, tseq.timestamps[offset + 2].size()); |
| 1020 | CheckAscending(tseq.timestamps[offset + 2]); |
| 1021 | } |
| 1022 | |
| 1023 | // Test handling of event sequences in the aggregated profile. |
| 1024 | TEST(CountersTest, AggregateEventSequences) { |
no test coverage detected