| 1093 | } |
| 1094 | |
| 1095 | void ValidateSampler(const StreamingSampler<int, 10>& sampler, int expected_num, |
| 1096 | int expected_period, int expected_delta) { |
| 1097 | const int* samples = NULL; |
| 1098 | int num_samples; |
| 1099 | int period; |
| 1100 | |
| 1101 | samples = sampler.GetSamples(&num_samples, &period); |
| 1102 | EXPECT_TRUE(samples != NULL); |
| 1103 | EXPECT_EQ(num_samples, expected_num); |
| 1104 | EXPECT_EQ(period, expected_period); |
| 1105 | |
| 1106 | for (int i = 0; i < expected_num - 1; ++i) { |
| 1107 | EXPECT_EQ(samples[i] + expected_delta, samples[i + 1]) << i; |
| 1108 | } |
| 1109 | } |
| 1110 | |
| 1111 | TEST(CountersTest, StreamingSampler) { |
| 1112 | StreamingSampler<int, 10> sampler(500); |