return NAN;
}
pthread_mutex_lock(&dist->mutex);
- if (dist->tree[0].bucket_counter == 0)
+ if (dist->tree[0].bucket_counter == 0) {
+ pthread_mutex_unlock(&dist->mutex);
return NAN;
+ }
uint64_t counter = ceil(dist->tree[0].bucket_counter * percent / 100.0);
double percentile =
tree_get_counter(dist, 0, 0, dist->num_buckets - 1, counter);
return NAN;
pthread_mutex_lock(&dist->mutex);
if (dist->tree[0].bucket_counter == 0) {
+ pthread_mutex_unlock(&dist->mutex);
return NAN;
}
double average = dist->total_sum / dist->tree[0].bucket_counter;
pthread_mutex_unlock(&d1->mutex);
return 0;
-}
\ No newline at end of file
+}
for (size_t j = 0; j < cases[i].num_gauges; j++) {
distribution_update(cases[i].dist, cases[i].update_gauges[j]);
}
+ EXPECT_EQ_DOUBLE(cases[i].want_average,
+ distribution_average(cases[i].dist));
+ /* Check it second time for deadlocks. */
EXPECT_EQ_DOUBLE(cases[i].want_average,
distribution_average(cases[i].dist));
distribution_destroy(cases[i].dist);
for (size_t j = 0; j < cases[i].num_gauges; j++) {
distribution_update(cases[i].dist, cases[i].update_gauges[j]);
}
+ EXPECT_EQ_DOUBLE(cases[i].want_percentile,
+ distribution_percentile(cases[i].dist, cases[i].percent));
+ /* Check it second time for deadlocks. */
EXPECT_EQ_DOUBLE(cases[i].want_percentile,
distribution_percentile(cases[i].dist, cases[i].percent));
if (cases[i].want_err != 0)