+static size_t latency_to_bucket (ping_context_t *ctx, double latency) /* {{{ */
+{
+ size_t bucket;
+
+ /* latency is in ms, opt_interval is in s. */
+ bucket = (size_t) ((latency * (ctx->latency_histogram_size - 1))
+ / (1000.0 * opt_interval));
+ if (bucket >= ctx->latency_histogram_size)
+ bucket = ctx->latency_histogram_size - 1;
+
+ return (bucket);
+} /* }}} size_t latency_to_bucket */
+