clang-format

pull/12891/head
Craig Tiller 7 years ago
parent 3cf8d50d1e
commit f0a2412338
  1. 75
      test/core/debug/stats_test.cc

@ -88,41 +88,46 @@ class HistogramTest : public ::testing::TestWithParam<int> {};
TEST_P(HistogramTest, IncHistogram) { TEST_P(HistogramTest, IncHistogram) {
const int kHistogram = GetParam(); const int kHistogram = GetParam();
std::vector<std::thread> threads; std::vector<std::thread> threads;
int cur_bucket = 0; int cur_bucket = 0;
auto run = [kHistogram](const std::vector<int>& test_values, int expected_bucket) { auto run = [kHistogram](const std::vector<int>& test_values,
gpr_log(GPR_DEBUG, "expected_bucket:%d nvalues=%" PRIdPTR, expected_bucket, test_values.size()); int expected_bucket) {
for (auto j : test_values) { gpr_log(GPR_DEBUG, "expected_bucket:%d nvalues=%" PRIdPTR, expected_bucket,
Snapshot snapshot; test_values.size());
for (auto j : test_values) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; Snapshot snapshot;
grpc_stats_inc_histogram[kHistogram](&exec_ctx, j);
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_stats_inc_histogram[kHistogram](&exec_ctx, j);
auto delta = snapshot.delta(); grpc_exec_ctx_finish(&exec_ctx);
EXPECT_EQ(delta.histograms[grpc_stats_histo_start[kHistogram] + auto delta = snapshot.delta();
expected_bucket],
1) EXPECT_EQ(
<< "\nhistogram:" << kHistogram delta
<< "\nexpected_bucket:" << expected_bucket .histograms[grpc_stats_histo_start[kHistogram] + expected_bucket],
<< "\nj:" << j; 1)
} << "\nhistogram:" << kHistogram
}; << "\nexpected_bucket:" << expected_bucket << "\nj:" << j;
std::vector<int> test_values; }
for (int j = -1000; };
j < grpc_stats_histo_bucket_boundaries std::vector<int> test_values;
[kHistogram][grpc_stats_histo_buckets[kHistogram] - 1] + for (int j = -1000;
1000; j <
j ++) { grpc_stats_histo_bucket_boundaries[kHistogram]
int expected_bucket = FindExpectedBucket(kHistogram, j); [grpc_stats_histo_buckets[kHistogram] -
if (cur_bucket != expected_bucket) { 1] +
threads.emplace_back([test_values, run, cur_bucket]() { run(test_values, cur_bucket); }); 1000;
cur_bucket = expected_bucket; j++) {
test_values.clear(); int expected_bucket = FindExpectedBucket(kHistogram, j);
} if (cur_bucket != expected_bucket) {
test_values.push_back(j); threads.emplace_back(
} [test_values, run, cur_bucket]() { run(test_values, cur_bucket); });
run(test_values, cur_bucket); cur_bucket = expected_bucket;
test_values.clear();
}
test_values.push_back(j);
}
run(test_values, cur_bucket);
for (auto& t : threads) { for (auto& t : threads) {
t.join(); t.join();
} }

Loading…
Cancel
Save