double percentile = Percentile.getPercentile(args);
return (T) new Percentile(histogram.getValueAtPercentile(percentile));
} else if (clazz == Histogram.class) {
int buckets = Histogram.getBuckets(args);
double percentile = Histogram.getPercentile(args);
AbstractHistogram.AllValues values = histogram.allValues();
ArrayList<Long> ranges = new ArrayList<>();
ArrayList<Long> counts = new ArrayList<>();
long min = Math.max(histogram.getMinValue(), 1);
long max = Math.max(histogram.getValueAtPercentile(percentile), 1);
if (max < min) max = Math.max(histogram.getMaxValue(), min + 1);