/// <summary> Compute a percentile from the underlying rolling buckets of values. /// <p> /// For performance reasons it maintains a single snapshot of the sorted values from all buckets that is re-generated each time the bucket rotates. /// </p> /// This means that if a bucket is 5000ms, then this method will re-compute a percentile at most once every 5000ms. /// /// <param name="percentile">value such as 99 (99th percentile), 99.5 (99.5th percentile), 50 (median, 50th percentile) to compute and retrieve percentile from rolling buckets.</param> /// <returns>percentile value</returns> /// </summary> public int GetPercentile(double percentile) { if (!this.enabled.Value) { return(-1); } // fetch the current snapshot return(CurrentPercentileSnapshot.GetPercentile(percentile)); }
/** * Compute a percentile from the underlying rolling buckets of values. * <p> * For performance reasons it maintains a single snapshot of the sorted values from all buckets that is re-generated each time the bucket rotates. * <p> * This means that if a bucket is 5000ms, then this method will re-compute a percentile at most once every 5000ms. * * @param percentile * value such as 99 (99th percentile), 99.5 (99.5th percentile), 50 (median, 50th percentile) to compute and retrieve percentile from rolling buckets. * @return int percentile value */ public int GetPercentile(double percentile) { /* no-op if disabled */ if (!enabled) { return(-1); } // force logic to move buckets forward in case other requests aren't making it happen GetCurrentBucket(); // fetch the current snapshot return(CurrentPercentileSnapshot.GetPercentile(percentile)); }