File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -30,12 +30,10 @@ Histogram::Histogram(const BucketBoundaries& buckets)
30
30
}
31
31
32
32
void Histogram::Observe (const double value) {
33
- // TODO: determine bucket list size at which binary search would be faster
34
- const auto bucket_index = static_cast <std::size_t >(std::distance (
35
- bucket_boundaries_.begin (),
36
- std::find_if (
37
- std::begin (bucket_boundaries_), std::end (bucket_boundaries_),
38
- [value](const double boundary) { return boundary >= value; })));
33
+ const auto bucket_index = static_cast <std::size_t >(
34
+ std::distance (bucket_boundaries_.begin (),
35
+ std::lower_bound (bucket_boundaries_.begin (),
36
+ bucket_boundaries_.end (), value)));
39
37
40
38
std::lock_guard<std::mutex> lock (mutex_);
41
39
sum_.Increment (value);
You can’t perform that action at this time.
0 commit comments