private double percentile(double percentile) {
        long targetCount = Math.round(totalQueries * percentile);
        long currentCount = 0;
        int index = 0;
        while (currentCount < targetCount && index < SLOTS) {
            currentCount += latencyHistogram[index];
            ++index;
        }
        if (index == SLOTS) {
            return maxLatency;
        }
        return toLatency(currentCount == targetCount ? index + 1 : index);
    }
Various metrics stored during query execution

@author bjorncs
predicate-search/src/main/java/com/yahoo/search/predicate/benchmarks/ResultMetrics.java