Java Code Examples for org.HdrHistogram.Histogram#getValueAtPercentile()

The following examples show how to use org.HdrHistogram.Histogram#getValueAtPercentile() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenLoopClient.java    From grpc-nebula-java with Apache License 2.0 6 votes vote down vote up
private void printStats(Histogram histogram, long elapsedTime) {
  long latency50 = histogram.getValueAtPercentile(50);
  long latency90 = histogram.getValueAtPercentile(90);
  long latency95 = histogram.getValueAtPercentile(95);
  long latency99 = histogram.getValueAtPercentile(99);
  long latency999 = histogram.getValueAtPercentile(99.9);
  long latencyMax = histogram.getValueAtPercentile(100);
  long queriesPerSecond = histogram.getTotalCount() * 1000000000L / elapsedTime;

  StringBuilder values = new StringBuilder();
  values.append("Server Payload Size:            ").append(config.serverPayload).append('\n')
        .append("Client Payload Size:            ").append(config.clientPayload).append('\n')
        .append("50%ile Latency (in micros):     ").append(latency50).append('\n')
        .append("90%ile Latency (in micros):     ").append(latency90).append('\n')
        .append("95%ile Latency (in micros):     ").append(latency95).append('\n')
        .append("99%ile Latency (in micros):     ").append(latency99).append('\n')
        .append("99.9%ile Latency (in micros):   ").append(latency999).append('\n')
        .append("Maximum Latency (in micros):    ").append(latencyMax).append('\n')
        .append("Actual QPS:                     ").append(queriesPerSecond).append('\n')
        .append("Target QPS:                     ").append(config.targetQps).append('\n');
  System.out.println(values);
}
 
Example 2
Source File: AsyncClient.java    From grpc-nebula-java with Apache License 2.0 6 votes vote down vote up
private void printStats(Histogram histogram, long elapsedTime) {
  long latency50 = histogram.getValueAtPercentile(50);
  long latency90 = histogram.getValueAtPercentile(90);
  long latency95 = histogram.getValueAtPercentile(95);
  long latency99 = histogram.getValueAtPercentile(99);
  long latency999 = histogram.getValueAtPercentile(99.9);
  long latencyMax = histogram.getValueAtPercentile(100);
  long queriesPerSecond = histogram.getTotalCount() * 1000000000L / elapsedTime;

  StringBuilder values = new StringBuilder();
  values.append("Channels:                       ").append(config.channels).append('\n')
        .append("Outstanding RPCs per Channel:   ")
        .append(config.outstandingRpcsPerChannel).append('\n')
        .append("Server Payload Size:            ").append(config.serverPayload).append('\n')
        .append("Client Payload Size:            ").append(config.clientPayload).append('\n')
        .append("50%ile Latency (in micros):     ").append(latency50).append('\n')
        .append("90%ile Latency (in micros):     ").append(latency90).append('\n')
        .append("95%ile Latency (in micros):     ").append(latency95).append('\n')
        .append("99%ile Latency (in micros):     ").append(latency99).append('\n')
        .append("99.9%ile Latency (in micros):   ").append(latency999).append('\n')
        .append("Maximum Latency (in micros):    ").append(latencyMax).append('\n')
        .append("QPS:                            ").append(queriesPerSecond).append('\n');
  System.out.println(values);
}
 
Example 3
Source File: SoftLatencyEvaluator.java    From maestro-java with Apache License 2.0 6 votes vote down vote up
@Override
public synchronized void record(final Histogram histogram) {
    long maxRecordedValue = histogram.getValueAtPercentile(this.defaultPercentile);

    if (logger.isTraceEnabled()) {
        logger.trace("Checking the current latency: {} x {}", maxRecordedValue, getMaxValue());
    }

    if (maxRecordedValue > getMaxValue()) {
        logger.warn("The maximum recorded latency ({} us) exceeds the maximum allowed value of ({} us) at percentile",
                maxRecordedValue, getMaxValue());

        setEvalFailed();
    }

    mean = histogram.getMean();
}
 
Example 4
Source File: Recorder.java    From grpc-proxy with Apache License 2.0 6 votes vote down vote up
public Snapshot interval() {
  final IntervalCount requestCount = count.interval();
  final IntervalCount responseTimeCount = responseTime.interval();
  final Histogram h = latency.getIntervalHistogram(histogram);
  final long c = requestCount.count();
  final double x = requestCount.rate();
  final long satisfied = h.getCountBetweenValues(0, goalLatency);
  final long tolerating = h.getCountBetweenValues(goalLatency, goalLatency * 4);
  final double p50 = h.getValueAtPercentile(50) * 1e-6;
  final double p90 = h.getValueAtPercentile(90) * 1e-6;
  final double p99 = h.getValueAtPercentile(99) * 1e-6;
  final double p999 = h.getValueAtPercentile(99.9) * 1e-6;
  this.histogram = h;
  final double r, n, apdex;
  if (c == 0) {
    r = n = apdex = 0;
  } else {
    r = responseTimeCount.rate() / c * 1e-6;
    n = x * r;
    apdex = Math.min(1.0, (satisfied + (tolerating / 2.0)) / c);
  }
  return new AutoValue_Snapshot(c, x, n, r, p50, p90, p99, p999, apdex);
}
 
Example 5
Source File: HdrReservoir.java    From rolling-metrics with Apache License 2.0 6 votes vote down vote up
static Snapshot takeSmartSnapshot(final double[] predefinedQuantiles, Histogram histogram) {
    final long max = histogram.getMaxValue();
    final long min = histogram.getMinValue();
    final double mean = histogram.getMean();
    final double median = histogram.getValueAtPercentile(50.0);
    final double stdDeviation = histogram.getStdDeviation();

    final double[] values = new double[predefinedQuantiles.length];
    for (int i = 0; i < predefinedQuantiles.length; i++) {
        double quantile = predefinedQuantiles[i];
        double percentile = quantile * 100.0;
        values[i] = histogram.getValueAtPercentile(percentile);
    }

    return createSmartSnapshot(predefinedQuantiles, max, min, mean, median, stdDeviation, values);
}
 
Example 6
Source File: OpenLoopClient.java    From grpc-java with Apache License 2.0 6 votes vote down vote up
private void printStats(Histogram histogram, long elapsedTime) {
  long latency50 = histogram.getValueAtPercentile(50);
  long latency90 = histogram.getValueAtPercentile(90);
  long latency95 = histogram.getValueAtPercentile(95);
  long latency99 = histogram.getValueAtPercentile(99);
  long latency999 = histogram.getValueAtPercentile(99.9);
  long latencyMax = histogram.getValueAtPercentile(100);
  long queriesPerSecond = histogram.getTotalCount() * 1000000000L / elapsedTime;

  StringBuilder values = new StringBuilder();
  values.append("Server Payload Size:            ").append(config.serverPayload).append('\n')
        .append("Client Payload Size:            ").append(config.clientPayload).append('\n')
        .append("50%ile Latency (in micros):     ").append(latency50).append('\n')
        .append("90%ile Latency (in micros):     ").append(latency90).append('\n')
        .append("95%ile Latency (in micros):     ").append(latency95).append('\n')
        .append("99%ile Latency (in micros):     ").append(latency99).append('\n')
        .append("99.9%ile Latency (in micros):   ").append(latency999).append('\n')
        .append("Maximum Latency (in micros):    ").append(latencyMax).append('\n')
        .append("Actual QPS:                     ").append(queriesPerSecond).append('\n')
        .append("Target QPS:                     ").append(config.targetQps).append('\n');
  System.out.println(values);
}
 
Example 7
Source File: AsyncClient.java    From grpc-java with Apache License 2.0 6 votes vote down vote up
private void printStats(Histogram histogram, long elapsedTime) {
  long latency50 = histogram.getValueAtPercentile(50);
  long latency90 = histogram.getValueAtPercentile(90);
  long latency95 = histogram.getValueAtPercentile(95);
  long latency99 = histogram.getValueAtPercentile(99);
  long latency999 = histogram.getValueAtPercentile(99.9);
  long latencyMax = histogram.getValueAtPercentile(100);
  long queriesPerSecond = histogram.getTotalCount() * 1000000000L / elapsedTime;

  StringBuilder values = new StringBuilder();
  values.append("Channels:                       ").append(config.channels).append('\n')
        .append("Outstanding RPCs per Channel:   ")
        .append(config.outstandingRpcsPerChannel).append('\n')
        .append("Server Payload Size:            ").append(config.serverPayload).append('\n')
        .append("Client Payload Size:            ").append(config.clientPayload).append('\n')
        .append("50%ile Latency (in micros):     ").append(latency50).append('\n')
        .append("90%ile Latency (in micros):     ").append(latency90).append('\n')
        .append("95%ile Latency (in micros):     ").append(latency95).append('\n')
        .append("99%ile Latency (in micros):     ").append(latency99).append('\n')
        .append("99.9%ile Latency (in micros):   ").append(latency999).append('\n')
        .append("Maximum Latency (in micros):    ").append(latencyMax).append('\n')
        .append("QPS:                            ").append(queriesPerSecond).append('\n');
  System.out.println(values);
}
 
Example 8
Source File: HistogramLogProcessor.java    From hazelcast-simulator with Apache License 2.0 6 votes vote down vote up
protected Object[] buildRegularHistogramStatistics(Histogram intervalHistogram, Histogram accumulatedRegularHistogram) {
    return new Object[]{((intervalHistogram.getEndTimeStamp() / 1000.0) - logReader.getStartTimeSec()),
            // values recorded during the last reporting interval
            intervalHistogram.getTotalCount(),
            intervalHistogram.getValueAtPercentile(50.0) / config.outputValueUnitRatio,
            intervalHistogram.getValueAtPercentile(90.0) / config.outputValueUnitRatio,
            intervalHistogram.getMaxValue() / config.outputValueUnitRatio,
            // values recorded from the beginning until now
            accumulatedRegularHistogram.getTotalCount(),
            accumulatedRegularHistogram.getValueAtPercentile(50.0) / config.outputValueUnitRatio,
            accumulatedRegularHistogram.getValueAtPercentile(90.0) / config.outputValueUnitRatio,
            accumulatedRegularHistogram.getValueAtPercentile(99.0) / config.outputValueUnitRatio,
            accumulatedRegularHistogram.getValueAtPercentile(99.9) / config.outputValueUnitRatio,
            accumulatedRegularHistogram.getValueAtPercentile(99.99) / config.outputValueUnitRatio,
            accumulatedRegularHistogram.getMaxValue() / config.outputValueUnitRatio};
}
 
Example 9
Source File: HistogramLogReader.java    From artio with Apache License 2.0 5 votes vote down vote up
private static double scaledPercentile(
    final Histogram histogram,
    final double scalingFactor,
    final double percentile)
{
    return histogram.getValueAtPercentile(percentile) / scalingFactor;
}
 
Example 10
Source File: SimulatorHistogramLogProcessor.java    From hazelcast-simulator with Apache License 2.0 4 votes vote down vote up
protected Object[] buildRegularHistogramStatistics(Histogram intervalHistogram, Histogram accumulatedHistogram) {
    double intervalThroughput = ((double) (intervalHistogram.getTotalCount())
            / (intervalHistogram.getEndTimeStamp() - intervalHistogram.getStartTimeStamp()));

    double totalThroughput = ((double) accumulatedHistogram.getTotalCount())
            / (accumulatedHistogram.getEndTimeStamp() - accumulatedHistogram.getStartTimeStamp());

    return new Object[]{
            ((intervalHistogram.getEndTimeStamp() / 1000.0) - logReader.getStartTimeSec()),
            (intervalHistogram.getEndTimeStamp() / 1000.0),
            // values recorded during the last reporting interval
            intervalHistogram.getTotalCount(),
            intervalHistogram.getValueAtPercentile(25.0) / config.outputValueUnitRatio,
            intervalHistogram.getValueAtPercentile(50.0) / config.outputValueUnitRatio,
            intervalHistogram.getValueAtPercentile(75.0) / config.outputValueUnitRatio,
            intervalHistogram.getValueAtPercentile(90.0) / config.outputValueUnitRatio,
            intervalHistogram.getValueAtPercentile(99.0) / config.outputValueUnitRatio,
            intervalHistogram.getValueAtPercentile(99.9) / config.outputValueUnitRatio,
            intervalHistogram.getValueAtPercentile(99.99) / config.outputValueUnitRatio,
            intervalHistogram.getValueAtPercentile(99.999) / config.outputValueUnitRatio,
            intervalHistogram.getMinValue() / config.outputValueUnitRatio,
            intervalHistogram.getMaxValue() / config.outputValueUnitRatio,
            intervalHistogram.getMean() / config.outputValueUnitRatio,
            intervalHistogram.getStdDeviation() / config.outputValueUnitRatio,
            intervalThroughput / config.outputValueUnitRatio,

            // values recorded from the beginning until now
            accumulatedHistogram.getTotalCount(),
            accumulatedHistogram.getValueAtPercentile(25.0) / config.outputValueUnitRatio,
            accumulatedHistogram.getValueAtPercentile(50.0) / config.outputValueUnitRatio,
            accumulatedHistogram.getValueAtPercentile(75.0) / config.outputValueUnitRatio,
            accumulatedHistogram.getValueAtPercentile(90.0) / config.outputValueUnitRatio,
            accumulatedHistogram.getValueAtPercentile(99.0) / config.outputValueUnitRatio,
            accumulatedHistogram.getValueAtPercentile(99.9) / config.outputValueUnitRatio,
            accumulatedHistogram.getValueAtPercentile(99.99) / config.outputValueUnitRatio,
            accumulatedHistogram.getValueAtPercentile(99.999) / config.outputValueUnitRatio,
            accumulatedHistogram.getMinValue() / config.outputValueUnitRatio,
            accumulatedHistogram.getMaxValue() / config.outputValueUnitRatio,
            accumulatedHistogram.getMean() / config.outputValueUnitRatio,
            accumulatedHistogram.getStdDeviation() / config.outputValueUnitRatio,
            totalThroughput / config.outputValueUnitRatio,
    };
}
 
Example 11
Source File: TestPerformanceTracker.java    From hazelcast-simulator with Apache License 2.0 4 votes vote down vote up
private void makeUpdate(long updateIntervalMillis, long currentTimeMillis) {
    Map<String, Probe> probeMap = testContainer.getProbeMap();
    Map<String, Histogram> intervalHistograms = new HashMap<>(probeMap.size());

    long intervalPercentileLatency = -1;
    double intervalMean = -1;
    long intervalMaxLatency = -1;

    long iterations = testContainer.iteration() - iterationsDuringWarmup;
    long intervalOperationCount = iterations - lastIterations;

    for (Map.Entry<String, Probe> entry : probeMap.entrySet()) {
        String probeName = entry.getKey();
        Probe probe = entry.getValue();
        if (!(probe instanceof HdrProbe)) {
            continue;
        }

        HdrProbe hdrProbe = (HdrProbe) probe;
        Histogram intervalHistogram = hdrProbe.getRecorder().getIntervalHistogram();
        intervalHistogram.setStartTimeStamp(lastUpdateMillis);
        intervalHistogram.setEndTimeStamp(currentTimeMillis);
        intervalHistograms.put(probeName, intervalHistogram);

        long percentileValue = intervalHistogram.getValueAtPercentile(INTERVAL_LATENCY_PERCENTILE);
        if (percentileValue > intervalPercentileLatency) {
            intervalPercentileLatency = percentileValue;
        }

        double meanLatency = intervalHistogram.getMean();
        if (meanLatency > intervalMean) {
            intervalMean = meanLatency;
        }

        long maxValue = intervalHistogram.getMaxValue();
        if (maxValue > intervalMaxLatency) {
            intervalMaxLatency = maxValue;
        }

        if (probe.isPartOfTotalThroughput()) {
            intervalOperationCount += intervalHistogram.getTotalCount();
        }
    }

    this.intervalHistogramMap = intervalHistograms;

    this.intervalLatency999PercentileNanos = intervalPercentileLatency;
    this.intervalLatencyAvgNanos = intervalMean;
    this.intervalLatencyMaxNanos = intervalMaxLatency;

    this.intervalOperationCount = intervalOperationCount;
    this.totalOperationCount += intervalOperationCount;

    long intervalTimeDelta = currentTimeMillis - lastUpdateMillis;
    long totalTimeDelta = currentTimeMillis - testContainer.getRunStartedMillis();

    this.intervalThroughput = (intervalOperationCount * ONE_SECOND_IN_MILLIS) / (double) intervalTimeDelta;
    this.totalThroughput = (totalOperationCount * ONE_SECOND_IN_MILLIS / (double) totalTimeDelta);

    this.lastIterations = iterations;
    this.nextUpdateMillis += updateIntervalMillis;
    this.lastUpdateMillis = currentTimeMillis;
}