|
|
|
@ -89,8 +89,10 @@ TEST_P(HistogramTest, IncHistogram) { |
|
|
|
|
const int kHistogram = GetParam(); |
|
|
|
|
std::vector<std::thread> threads; |
|
|
|
|
int cur_bucket = 0; |
|
|
|
|
auto run = [kHistogram](const std::vector<int>& test_values, int expected_bucket) { |
|
|
|
|
gpr_log(GPR_DEBUG, "expected_bucket:%d nvalues=%" PRIdPTR, expected_bucket, test_values.size()); |
|
|
|
|
auto run = [kHistogram](const std::vector<int>& test_values, |
|
|
|
|
int expected_bucket) { |
|
|
|
|
gpr_log(GPR_DEBUG, "expected_bucket:%d nvalues=%" PRIdPTR, expected_bucket, |
|
|
|
|
test_values.size()); |
|
|
|
|
for (auto j : test_values) { |
|
|
|
|
Snapshot snapshot; |
|
|
|
|
|
|
|
|
@ -100,23 +102,26 @@ TEST_P(HistogramTest, IncHistogram) { |
|
|
|
|
|
|
|
|
|
auto delta = snapshot.delta(); |
|
|
|
|
|
|
|
|
|
EXPECT_EQ(delta.histograms[grpc_stats_histo_start[kHistogram] + |
|
|
|
|
expected_bucket], |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
delta |
|
|
|
|
.histograms[grpc_stats_histo_start[kHistogram] + expected_bucket], |
|
|
|
|
1) |
|
|
|
|
<< "\nhistogram:" << kHistogram |
|
|
|
|
<< "\nexpected_bucket:" << expected_bucket |
|
|
|
|
<< "\nj:" << j; |
|
|
|
|
<< "\nexpected_bucket:" << expected_bucket << "\nj:" << j; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
std::vector<int> test_values; |
|
|
|
|
for (int j = -1000; |
|
|
|
|
j < grpc_stats_histo_bucket_boundaries |
|
|
|
|
[kHistogram][grpc_stats_histo_buckets[kHistogram] - 1] + |
|
|
|
|
j < |
|
|
|
|
grpc_stats_histo_bucket_boundaries[kHistogram] |
|
|
|
|
[grpc_stats_histo_buckets[kHistogram] - |
|
|
|
|
1] + |
|
|
|
|
1000; |
|
|
|
|
j ++) { |
|
|
|
|
j++) { |
|
|
|
|
int expected_bucket = FindExpectedBucket(kHistogram, j); |
|
|
|
|
if (cur_bucket != expected_bucket) { |
|
|
|
|
threads.emplace_back([test_values, run, cur_bucket]() { run(test_values, cur_bucket); }); |
|
|
|
|
threads.emplace_back( |
|
|
|
|
[test_values, run, cur_bucket]() { run(test_values, cur_bucket); }); |
|
|
|
|
cur_bucket = expected_bucket; |
|
|
|
|
test_values.clear(); |
|
|
|
|
} |
|
|
|
|