errors++;
}
@Override
public <T> T getRepresentation(Class<T> clazz, Object... args) {
AbstractHistogram histogram = getHistogram();
if (clazz == DefaultOutcome.class) {
return (T) new DefaultOutcome(histogram.getTotalCount(), errors, histogram.getMean(), histogram.getMaxValue());
} else if (clazz == MeanAndDev.class) {
return (T) new MeanAndDev(histogram.getMean(), histogram.getStdDeviation());
} else if (clazz == Throughput.class) {
return (T) Throughput.compute(histogram.getTotalCount(), histogram.getMean(), args);
} else if (clazz == Percentile.class) {
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);
double exponent = Math.pow((double) max / (double) min, 1d / buckets);
double current = min * exponent;
long accCount = 0, lastCount = 0;
for (HistogramIterationValue value : values) {
accCount += value.getCountAddedInThisIterationStep();