Package org.HdrHistogram

Examples of org.HdrHistogram.Histogram


            System.out.println("@ " + (TimeServices.nanoTime() - startTime) + " nsec after start:");
            System.out.println("Estimated interval = " +
                    latencyStats.getIntervalEstimator().getEstimatedInterval(lastTime));

            Histogram accumulatedHistogram = latencyStats.getAccumulatedHistogram();
            Histogram intervalHistogram = latencyStats.getIntervalHistogram();

            System.out.println("Accumulated Average latency for 5msec sleeps: " +
                    accumulatedHistogram.getMean() + ", count = " + accumulatedHistogram.getTotalCount());
            System.out.println("Interval Average latency for 5msec sleeps: " +
                    intervalHistogram.getMean() + ", count = " + intervalHistogram.getTotalCount());

            Assert.assertEquals("Accumulated total count should be 2000", 2000, accumulatedHistogram.getTotalCount());

            System.out.println("Pausing detector threads for 5 seconds:");
            pauseDetector.stallDetectorThreads(0x7, 5000 * MSEC);
            TimeUnit.NANOSECONDS.sleep(1 * MSEC); // Make sure things have some time to propagate

            // @ 15 sec from start

            // Report without forcing interval measurement update:

            System.out.println("@ " + (TimeServices.nanoTime() - startTime) + " nsec after start:");
            System.out.println("Estimated interval = " +
                    latencyStats.getIntervalEstimator().getEstimatedInterval(TimeServices.nanoTime()));
            accumulatedHistogram = latencyStats.getAccumulatedHistogram();
            intervalHistogram = latencyStats.getIntervalHistogram();

            System.out.println("Post-pause, pre-observation Accumulated Average latency for 5msec sleeps: " +
                    accumulatedHistogram.getMean() + ", count = " + accumulatedHistogram.getTotalCount());
            System.out.println("Post-pause, pre-observation Interval Average latency for 5msec sleeps: " +
                    intervalHistogram.getMean() + ", count = " + intervalHistogram.getTotalCount());

            Assert.assertEquals("Accumulated total count should be 2000", 2000, accumulatedHistogram.getTotalCount());

            // Still @ 15 sec from start
            System.out.println("\nForcing Interval Update:\n");
            latencyStats.forceIntervalSample();

            System.out.println("@ " + (TimeServices.nanoTime() - startTime) + " nsec after start:");
            System.out.println("Estimated interval = " +
                    latencyStats.getIntervalEstimator().getEstimatedInterval(TimeServices.nanoTime()));
            accumulatedHistogram = latencyStats.getAccumulatedHistogram();
            intervalHistogram = latencyStats.getIntervalHistogram();

            System.out.println("Post-pause, post-observation Accumulated Average latency for 5msec sleeps: " +
                    accumulatedHistogram.getMean() + ", count = " + accumulatedHistogram.getTotalCount());
            System.out.println("Post-pause, post-observation Interval Average latency for 5msec sleeps: " +
                    intervalHistogram.getMean() + ", count = " + intervalHistogram.getTotalCount());

            Assert.assertEquals("Accumulated total count should be 2000", 2998, accumulatedHistogram.getTotalCount());

            pauseDetector.skipConsensusTimeTo(TimeServices.nanoTime() + (500 * MSEC));
            TimeServices.moveTimeForwardMsec(500);
            TimeUnit.NANOSECONDS.sleep(1 * MSEC); // Make sure things have some time to propagate

            // @ 15.5 sec from start
            System.out.println("\nForcing Interval Update:\n");
            latencyStats.forceIntervalSample();

            System.out.println("@ " + (TimeServices.nanoTime() - startTime) + " nsec after start:");
            System.out.println("Estimated interval = " +
                    latencyStats.getIntervalEstimator().getEstimatedInterval(TimeServices.nanoTime()));
            accumulatedHistogram = latencyStats.getAccumulatedHistogram();
            intervalHistogram = latencyStats.getIntervalHistogram();

            System.out.println("Post-pause Accumulated Average latency for 5msec sleeps: " +
                    accumulatedHistogram.getMean() + ", count = " + accumulatedHistogram.getTotalCount());
            System.out.println("Post-pause Interval Average latency for 5msec sleeps: " +
                    intervalHistogram.getMean() + ", count = " + intervalHistogram.getTotalCount());

            Assert.assertEquals("Accumulated total count should be 2000", 2998, accumulatedHistogram.getTotalCount());

            pauseDetector.skipConsensusTimeTo(TimeServices.nanoTime() + (500 * MSEC));
            TimeServices.moveTimeForwardMsec(500);
            TimeUnit.NANOSECONDS.sleep(1 * MSEC); // Make sure things have some time to propagate

            // @ 16 sec from start
            System.out.println("\nForcing Interval Update:\n");
            latencyStats.forceIntervalSample();

            System.out.println("@ " + (TimeServices.nanoTime() - startTime) + " nsec after start:");
            System.out.println("Estimated interval = " +
                    latencyStats.getIntervalEstimator().getEstimatedInterval(TimeServices.nanoTime()));
            accumulatedHistogram = latencyStats.getAccumulatedHistogram();
            intervalHistogram = latencyStats.getIntervalHistogram();

            System.out.println("Post-pause Accumulated Average latency for 5msec sleeps: " +
                    accumulatedHistogram.getMean() + ", count = " + accumulatedHistogram.getTotalCount());
            System.out.println("Post-pause Interval Average latency for 5msec sleeps: " +
                    intervalHistogram.getMean() + ", count = " + intervalHistogram.getTotalCount());

            Assert.assertEquals("Accumulated total count should be 2999", 2998, accumulatedHistogram.getTotalCount());

            pauseDetector.skipConsensusTimeTo(TimeServices.nanoTime() + (2000 * MSEC));
            TimeServices.moveTimeForwardMsec(2000);
            TimeUnit.NANOSECONDS.sleep(1 * MSEC); // Make sure things have some time to propagate

            // @ 18 sec from start
            System.out.println("\nForcing Interval Update:\n");
            latencyStats.forceIntervalSample();

            System.out.println("@ " + (TimeServices.nanoTime() - startTime) + " nsec after start:");
            System.out.println("Estimated interval = " +
                    latencyStats.getIntervalEstimator().getEstimatedInterval(TimeServices.nanoTime()));
            accumulatedHistogram = latencyStats.getAccumulatedHistogram();
            intervalHistogram = latencyStats.getIntervalHistogram();

            System.out.println("Post-pause Accumulated Average latency for 5msec sleeps: " +
                    accumulatedHistogram.getMean() + ", count = " + accumulatedHistogram.getTotalCount());
            System.out.println("Post-pause Interval Average latency for 5msec sleeps: " +
                    intervalHistogram.getMean() + ", count = " + intervalHistogram.getTotalCount());

            Assert.assertEquals("Accumulated total count should be 2999", 2998, accumulatedHistogram.getTotalCount());

            for (int i = 0 ; i < 100; i++) {
                pauseDetector.skipConsensusTimeTo(TimeServices.nanoTime() + (5 * MSEC));
                TimeServices.moveTimeForwardMsec(5);
                long now = TimeServices.nanoTime();
                latencyStats.recordLatency(now - lastTime);
                lastTime = now;
            }

            pauseDetector.skipConsensusTimeTo(TimeServices.nanoTime() + (500 * MSEC));
            TimeServices.moveTimeForwardMsec(500);
            TimeUnit.NANOSECONDS.sleep(1 * MSEC); // Make sure things have some time to propagate

            // @ 19 sec from start
            System.out.println("\nForcing Interval Update:\n");
            latencyStats.forceIntervalSample();


            System.out.println("@ " + (TimeServices.nanoTime() - startTime) + " nsec after start:");
            System.out.println("Estimated interval = " +
                    latencyStats.getIntervalEstimator().getEstimatedInterval(TimeServices.nanoTime()));
            accumulatedHistogram = latencyStats.getAccumulatedHistogram();
            intervalHistogram = latencyStats.getIntervalHistogram();
            System.out.println("Post-pause Accumulated Average latency for 5msec sleeps: " +
                    accumulatedHistogram.getMean() + ", count = " + accumulatedHistogram.getTotalCount());
            System.out.println("Post-pause Interval Average latency for 5msec sleeps: " +
                    intervalHistogram.getMean() + ", count = " + intervalHistogram.getTotalCount());


            pauseDetector.skipConsensusTimeTo(TimeServices.nanoTime() + (500 * MSEC));
            TimeServices.moveTimeForwardMsec(500);
            TimeUnit.NANOSECONDS.sleep(1 * MSEC); // Make sure things have some time to propagate

            // @ 19.5 sec from start
            System.out.println("\nForcing Interval Update:\n");
            latencyStats.forceIntervalSample();

            System.out.println("@ " + (TimeServices.nanoTime() - startTime) + " nsec after start:");
            System.out.println("Estimated interval = " +
                    latencyStats.getIntervalEstimator().getEstimatedInterval(TimeServices.nanoTime()));
            accumulatedHistogram = latencyStats.getAccumulatedHistogram();
            intervalHistogram = latencyStats.getIntervalHistogram();
            System.out.println("Post-pause Accumulated Average latency for 5msec sleeps: " +
                    accumulatedHistogram.getMean() + ", count = " + accumulatedHistogram.getTotalCount());
            System.out.println("Post-pause Interval Average latency for 5msec sleeps: " +
                    intervalHistogram.getMean() + ", count = " + intervalHistogram.getTotalCount());

            Assert.assertEquals("Accumulated total count should be 2000", 3098, accumulatedHistogram.getTotalCount());
        } catch (InterruptedException ex) {

        }
View Full Code Here


        // Create alternating recording histograms:
        currentRecordingHistogram = new AtomicHistogram(lowestTrackableLatency, highestTrackableLatency, numberOfSignificantValueDigits);
        intervalRawDataHistogram = new AtomicHistogram(lowestTrackableLatency, highestTrackableLatency, numberOfSignificantValueDigits);

        // Create alternating pause correction histograms:
        currentPauseCorrectionsHistogram = new Histogram(lowestTrackableLatency, highestTrackableLatency, numberOfSignificantValueDigits);
        intervalPauseCorrectionsHistogram = new Histogram(lowestTrackableLatency, highestTrackableLatency, numberOfSignificantValueDigits);

        // Create accumulated Histograms:
        accumulatedHistogram = new Histogram(lowestTrackableLatency, highestTrackableLatency, numberOfSignificantValueDigits);
        uncorrectedAccumulatedHistogram = new Histogram(lowestTrackableLatency, highestTrackableLatency, numberOfSignificantValueDigits);

        // Create interval estimator:
        intervalEstimator = new TimeCappedMovingAverageIntervalEstimator(intervalEstimatorWindowLength,
                intervalEstimatorTimeCap, this.pauseDetector);
View Full Code Here

     * @return a copy of the latest interval latency histogram
     */
    public synchronized Histogram getIntervalHistogram() {
        try {
            recordingPhaser.readerLock();
            Histogram intervalHistogram = new Histogram(lowestTrackableLatency, highestTrackableLatency, numberOfSignificantValueDigits);
            getIntervalHistogramInto(intervalHistogram);
            return intervalHistogram;
        } finally {
            recordingPhaser.readerUnlock();
        }
View Full Code Here

     * @return a copy of the latest uncorrected interval latency histogram
     */
    public synchronized Histogram getUncorrectedIntervalHistogram() {
        try {
            recordingPhaser.readerLock();
            Histogram intervalHistogram = new Histogram(lowestTrackableLatency, highestTrackableLatency, numberOfSignificantValueDigits);
            getUncorrectedIntervalHistogramInto(intervalHistogram);
            return intervalHistogram;
        } finally {
            recordingPhaser.readerUnlock();
        }
View Full Code Here

        intervalRawDataHistogram = currentRecordingHistogram;
        currentRecordingHistogram = tempHistogram;
    }

    private void swapPauseCorrectionHistograms() {
        final Histogram tempHistogram = intervalPauseCorrectionsHistogram;
        intervalPauseCorrectionsHistogram = currentPauseCorrectionsHistogram;
        currentPauseCorrectionsHistogram = tempHistogram;
    }
View Full Code Here

     * integer between 0 and 5.
     */
    public StripedHistogram(long highestTrackableValue, int numberOfSignificantValueDigits) {
        this.highestTrackableValue = highestTrackableValue;
        this.numberOfSignificantValueDigits = numberOfSignificantValueDigits;
        this.mainHistogram = new Histogram(highestTrackableValue, numberOfSignificantValueDigits);
        this.hs = new Striped<AbstractHistogram>() {
            @Override
            protected AbstractHistogram newResource() {
                return new Histogram(StripedHistogram.this.highestTrackableValue, StripedHistogram.this.numberOfSignificantValueDigits);
            }
        };
    }
View Full Code Here

     * integer between 0 and 5.
     */
    public StripedHistogram(long highestTrackableValue, int numberOfSignificantValueDigits) {
        this.highestTrackableValue = highestTrackableValue;
        this.numberOfSignificantValueDigits = numberOfSignificantValueDigits;
        this.mainHistogram = new Histogram(highestTrackableValue, numberOfSignificantValueDigits);
        this.hs = new StripedResource<AbstractHistogram>() {
            @Override
            protected AbstractHistogram newResource() {
                return new Histogram(StripedHistogram.this.highestTrackableValue, StripedHistogram.this.numberOfSignificantValueDigits);
            }
        };
    }
View Full Code Here

TOP

Related Classes of org.HdrHistogram.Histogram

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.