|
16 | 16 |
|
17 | 17 | struct hdr_histogram |
18 | 18 | { |
19 | | - int64_t lowest_trackable_value; |
| 19 | + int64_t lowest_discernible_value; |
20 | 20 | int64_t highest_trackable_value; |
21 | 21 | int32_t unit_magnitude; |
22 | 22 | int32_t significant_figures; |
@@ -45,21 +45,21 @@ extern "C" { |
45 | 45 | * involved math on the input parameters this function it is tricky to stack allocate. |
46 | 46 | * The histogram should be released with hdr_close |
47 | 47 | * |
48 | | - * @param lowest_trackable_value The smallest possible value to be put into the |
49 | | - * histogram. |
| 48 | + * @param lowest_discernible_value The smallest possible value that is distinguishable from 0. |
| 49 | + * Must be a positive integer that is >= 1. May be internally rounded down to nearest power of 2. |
50 | 50 | * @param highest_trackable_value The largest possible value to be put into the |
51 | 51 | * histogram. |
52 | 52 | * @param significant_figures The level of precision for this histogram, i.e. the number |
53 | 53 | * of figures in a decimal number that will be maintained. E.g. a value of 3 will mean |
54 | 54 | * the results from the histogram will be accurate up to the first three digits. Must |
55 | 55 | * be a value between 1 and 5 (inclusive). |
56 | 56 | * @param result Output parameter to capture allocated histogram. |
57 | | - * @return 0 on success, EINVAL if lowest_trackable_value is < 1 or the |
| 57 | + * @return 0 on success, EINVAL if lowest_discernible_value is < 1 or the |
58 | 58 | * significant_figure value is outside of the allowed range, ENOMEM if malloc |
59 | 59 | * failed. |
60 | 60 | */ |
61 | 61 | int hdr_init( |
62 | | - int64_t lowest_trackable_value, |
| 62 | + int64_t lowest_discernible_value, |
63 | 63 | int64_t highest_trackable_value, |
64 | 64 | int significant_figures, |
65 | 65 | struct hdr_histogram** result); |
@@ -159,27 +159,27 @@ bool hdr_record_values_atomic(struct hdr_histogram* h, int64_t value, int64_t co |
159 | 159 | * Record a value in the histogram and backfill based on an expected interval. |
160 | 160 | * |
161 | 161 | * Records a value in the histogram, will round this value of to a precision at or better |
162 | | - * than the significant_figure specified at contruction time. This is specifically used |
| 162 | + * than the significant_figure specified at construction time. This is specifically used |
163 | 163 | * for recording latency. If the value is larger than the expected_interval then the |
164 | 164 | * latency recording system has experienced co-ordinated omission. This method fills in the |
165 | | - * values that would have occured had the client providing the load not been blocked. |
| 165 | + * values that would have occurred had the client providing the load not been blocked. |
166 | 166 |
|
167 | 167 | * @param h "This" pointer |
168 | 168 | * @param value Value to add to the histogram |
169 | 169 | * @param expected_interval The delay between recording values. |
170 | 170 | * @return false if the value is larger than the highest_trackable_value and can't be recorded, |
171 | 171 | * true otherwise. |
172 | 172 | */ |
173 | | -bool hdr_record_corrected_value(struct hdr_histogram* h, int64_t value, int64_t expexcted_interval); |
| 173 | +bool hdr_record_corrected_value(struct hdr_histogram* h, int64_t value, int64_t expected_interval); |
174 | 174 |
|
175 | 175 | /** |
176 | 176 | * Record a value in the histogram and backfill based on an expected interval. |
177 | 177 | * |
178 | 178 | * Records a value in the histogram, will round this value of to a precision at or better |
179 | | - * than the significant_figure specified at contruction time. This is specifically used |
| 179 | + * than the significant_figure specified at construction time. This is specifically used |
180 | 180 | * for recording latency. If the value is larger than the expected_interval then the |
181 | 181 | * latency recording system has experienced co-ordinated omission. This method fills in the |
182 | | - * values that would have occured had the client providing the load not been blocked. |
| 182 | + * values that would have occurred had the client providing the load not been blocked. |
183 | 183 | * |
184 | 184 | * Will record this value atomically, however the whole structure may appear inconsistent |
185 | 185 | * when read concurrently with this update. Do NOT mix calls to this method with calls |
@@ -191,7 +191,7 @@ bool hdr_record_corrected_value(struct hdr_histogram* h, int64_t value, int64_t |
191 | 191 | * @return false if the value is larger than the highest_trackable_value and can't be recorded, |
192 | 192 | * true otherwise. |
193 | 193 | */ |
194 | | -bool hdr_record_corrected_value_atomic(struct hdr_histogram* h, int64_t value, int64_t expexcted_interval); |
| 194 | +bool hdr_record_corrected_value_atomic(struct hdr_histogram* h, int64_t value, int64_t expected_interval); |
195 | 195 |
|
196 | 196 | /** |
197 | 197 | * Record a value in the histogram 'count' times. Applies the same correcting logic |
@@ -226,7 +226,7 @@ bool hdr_record_corrected_values_atomic(struct hdr_histogram* h, int64_t value, |
226 | 226 | /** |
227 | 227 | * Adds all of the values from 'from' to 'this' histogram. Will return the |
228 | 228 | * number of values that are dropped when copying. Values will be dropped |
229 | | - * if they around outside of h.lowest_trackable_value and |
| 229 | + * if they around outside of h.lowest_discernible_value and |
230 | 230 | * h.highest_trackable_value. |
231 | 231 | * |
232 | 232 | * @param h "This" pointer |
@@ -238,7 +238,7 @@ int64_t hdr_add(struct hdr_histogram* h, const struct hdr_histogram* from); |
238 | 238 | /** |
239 | 239 | * Adds all of the values from 'from' to 'this' histogram. Will return the |
240 | 240 | * number of values that are dropped when copying. Values will be dropped |
241 | | - * if they around outside of h.lowest_trackable_value and |
| 241 | + * if they around outside of h.lowest_discernible_value and |
242 | 242 | * h.highest_trackable_value. |
243 | 243 | * |
244 | 244 | * @param h "This" pointer |
@@ -272,6 +272,18 @@ int64_t hdr_max(const struct hdr_histogram* h); |
272 | 272 | */ |
273 | 273 | int64_t hdr_value_at_percentile(const struct hdr_histogram* h, double percentile); |
274 | 274 |
|
| 275 | +/** |
| 276 | + * Get the values at the given percentiles. |
| 277 | + * |
| 278 | + * @param h "This" pointer. |
| 279 | + * @param percentiles The ordered percentiles array to get the values for. |
| 280 | + * @param length Number of elements in the arrays. |
| 281 | + * @param values Destination array containing the values at the given percentiles. |
| 282 | + * The values array should be allocated by the caller. |
| 283 | + * @return 0 on success, ENOMEM if the provided destination array is null. |
| 284 | + */ |
| 285 | +int hdr_value_at_percentiles(const struct hdr_histogram *h, const double *percentiles, int64_t *values, size_t length); |
| 286 | + |
275 | 287 | /** |
276 | 288 | * Gets the standard deviation for the values in the histogram. |
277 | 289 | * |
@@ -465,7 +477,7 @@ int hdr_percentiles_print( |
465 | 477 | */ |
466 | 478 | struct hdr_histogram_bucket_config |
467 | 479 | { |
468 | | - int64_t lowest_trackable_value; |
| 480 | + int64_t lowest_discernible_value; |
469 | 481 | int64_t highest_trackable_value; |
470 | 482 | int64_t unit_magnitude; |
471 | 483 | int64_t significant_figures; |
@@ -478,7 +490,7 @@ struct hdr_histogram_bucket_config |
478 | 490 | }; |
479 | 491 |
|
480 | 492 | int hdr_calculate_bucket_config( |
481 | | - int64_t lowest_trackable_value, |
| 493 | + int64_t lowest_discernible_value, |
482 | 494 | int64_t highest_trackable_value, |
483 | 495 | int significant_figures, |
484 | 496 | struct hdr_histogram_bucket_config* cfg); |
@@ -492,7 +504,7 @@ int64_t hdr_next_non_equivalent_value(const struct hdr_histogram* h, int64_t val |
492 | 504 | int64_t hdr_median_equivalent_value(const struct hdr_histogram* h, int64_t value); |
493 | 505 |
|
494 | 506 | /** |
495 | | - * Used to reset counters after importing data manuallying into the histogram, used by the logging code |
| 507 | + * Used to reset counters after importing data manually into the histogram, used by the logging code |
496 | 508 | * and other custom serialisation tools. |
497 | 509 | */ |
498 | 510 | void hdr_reset_internal_counters(struct hdr_histogram* h); |
|