* STATS::ile * * Returns the fractile value such that frac fraction (in [0,1]) of samples * has a value less than the return value. **********************************************************************/
| 172 | * has a value less than the return value. |
| 173 | **********************************************************************/ |
| 174 | double STATS::ile(double frac) const { |
| 175 | if (buckets_ == NULL || total_count_ == 0) { |
| 176 | return static_cast<double>(rangemin_); |
| 177 | } |
| 178 | #if 0 |
| 179 | // TODO(rays) The existing code doesn't seem to be doing the right thing |
| 180 | // with target a double but this substitute crashes the code that uses it. |
| 181 | // Investigate and fix properly. |
| 182 | int target = IntCastRounded(frac * total_count_); |
| 183 | target = ClipToRange(target, 1, total_count_); |
| 184 | #else |
| 185 | double target = frac * total_count_; |
| 186 | target = ClipToRange(target, 1.0, static_cast<double>(total_count_)); |
| 187 | #endif |
| 188 | int sum = 0; |
| 189 | int index = 0; |
| 190 | for (index = 0; index < rangemax_ - rangemin_ && sum < target; |
| 191 | sum += buckets_[index++]); |
| 192 | if (index > 0) { |
| 193 | ASSERT_HOST(buckets_[index - 1] > 0); |
| 194 | return rangemin_ + index - |
| 195 | static_cast<double>(sum - target) / buckets_[index - 1]; |
| 196 | } else { |
| 197 | return static_cast<double>(rangemin_); |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | /********************************************************************** |
| 202 | * STATS::min_bucket |
no test coverage detected