Search in sources :

Example 1 with AtomicHistogram

use of org.HdrHistogram.AtomicHistogram in project LatencyUtils by LatencyUtils.

the class LatencyStats method swapRecordingHistograms.

private void swapRecordingHistograms() {
    final AtomicHistogram tempHistogram = inactiveRawDataHistogram;
    inactiveRawDataHistogram = activeRecordingHistogram;
    activeRecordingHistogram = tempHistogram;
}
Also used : AtomicHistogram(org.HdrHistogram.AtomicHistogram)

Example 2 with AtomicHistogram

use of org.HdrHistogram.AtomicHistogram in project graylog2-server by Graylog2.

the class HdrHistogram method getSnapshot.

@Override
public Snapshot getSnapshot() {
    final AtomicHistogram copy = hdrHistogram.copy();
    return new Snapshot() {

        @Override
        public double getValue(double quantile) {
            return copy.getValueAtPercentile(quantile * 100);
        }

        @Override
        public long[] getValues() {
            return new long[0];
        }

        @Override
        public int size() {
            return 0;
        }

        @Override
        public long getMax() {
            return copy.getMaxValue();
        }

        @Override
        public double getMean() {
            final double mean = copy.getMean();
            return Double.isNaN(mean) ? 0 : mean;
        }

        @Override
        public long getMin() {
            final long minValue = copy.getMinValue();
            return minValue == Long.MAX_VALUE ? 0 : minValue;
        }

        @Override
        public double getStdDev() {
            final double stdDeviation = copy.getStdDeviation();
            return Double.isNaN(stdDeviation) ? 0 : stdDeviation;
        }

        @Override
        public void dump(OutputStream output) {
            final PrintStream printStream;
            try {
                printStream = new PrintStream(output, false, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                throw new RuntimeException(e);
            }
            copy.outputPercentileDistribution(printStream, 1d);
        }
    };
}
Also used : Snapshot(com.codahale.metrics.Snapshot) PrintStream(java.io.PrintStream) OutputStream(java.io.OutputStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) AtomicHistogram(org.HdrHistogram.AtomicHistogram)

Aggregations

AtomicHistogram (org.HdrHistogram.AtomicHistogram)2 Snapshot (com.codahale.metrics.Snapshot)1 OutputStream (java.io.OutputStream)1 PrintStream (java.io.PrintStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1