private void populateStatsBuckets(long timeInNanos) { long timeInMillis = (timeInNanos + ONE_MILLION - 1) / ONE_MILLION; int index = 0; long upperInclusive = 1; while (upperInclusive < timeInMillis) { resizeUnderStats(index); underStatsMillis.get(index).incrementAndGet(); index++; upperInclusive <<= 1; } resizeUnderStats(index); underStatsMillis.get(index).incrementAndGet(); }
@Override public double getPercentCallsFinishedInMillis(int millis) { if (millis <= 0) { return 0.0; } long localTotalCalls = totalCalls; if (localTotalCalls == 0) { return 100.0; } long upper = 1; int comparisonPoint = 1; // comparisonPoint = 1 corresponds to % of numbers > 1 while (upper < millis) { upper <<= 1; comparisonPoint++; } resizeUnderStats(comparisonPoint); double prev = 1.0 - ((double) underStatsMillis.get(comparisonPoint - 1).get()) / localTotalCalls; double next = 1.0 - ((double) underStatsMillis.get(comparisonPoint).get()) / localTotalCalls; // lerp(x0, y0, x1, y1, x) -> y return 100.0 * lerp(upper / 2.0, prev, upper, next, millis); }
resizeUnderStats(comparisonPoint); comparisonPoint++; millis <<= 1; resizeUnderStats(comparisonPoint); prevPerc = percent; percent = 100.0 * ((double) underStatsMillis.get(comparisonPoint).get()) / localTotalCalls;
private void populateStatsBuckets(long timeInNanos) { long timeInMillis = (timeInNanos + ONE_MILLION - 1) / ONE_MILLION; int index = 0; long upperInclusive = 1; while (upperInclusive < timeInMillis) { resizeUnderStats(index); underStatsMillis.get(index).incrementAndGet(); index++; upperInclusive <<= 1; } resizeUnderStats(index); underStatsMillis.get(index).incrementAndGet(); }
@Override public double getPercentCallsFinishedInMillis(int millis) { if (millis <= 0) { return 0.0; } long localTotalCalls = totalCalls; if (localTotalCalls == 0) { return 100.0; } long upper = 1; int comparisonPoint = 1; // comparisonPoint = 1 corresponds to % of numbers > 1 while (upper < millis) { upper <<= 1; comparisonPoint++; } resizeUnderStats(comparisonPoint); double prev = 1.0 - ((double) underStatsMillis.get(comparisonPoint - 1).get()) / localTotalCalls; double next = 1.0 - ((double) underStatsMillis.get(comparisonPoint).get()) / localTotalCalls; // lerp(x0, y0, x1, y1, x) -> y return 100.0 * lerp(upper / 2.0, prev, upper, next, millis); }
resizeUnderStats(comparisonPoint); comparisonPoint++; millis <<= 1; resizeUnderStats(comparisonPoint); prevPerc = percent; percent = 100.0 * ((double) underStatsMillis.get(comparisonPoint).get()) / localTotalCalls;