/** * Get a new instance of an interval histogram, which will include a stable, consistent view of all value * counts accumulated since the last interval histogram was taken. * <p> * Calling {@link SingleWriterRecorder#getIntervalHistogram()} will reset * the value counts, and start accumulating value counts for the next interval. * * @return a histogram containing the value counts accumulated since the last interval histogram was taken. */ public synchronized Histogram getIntervalHistogram() { return getIntervalHistogram(null); }
boolean enforeContainingInstance) { validateFitAsReplacementHistogram(histogramToRecycle, enforeContainingInstance); inactiveHistogram = (InternalHistogram) histogramToRecycle; performIntervalSample(); Histogram sampledHistogram = inactiveHistogram;
@Override public void run() { final SingleWriterRecorder recorder = new SingleWriterRecorder(config.lowestTrackableValueInNanos(), config.highestTrackableValueInNanos(), config.numberOfSignificantValueDigits()); hiccupRecorder.join(); recorder.reset(); hiccupRecorder = new HiccupRecorder(config, recorder); intervalHistogram = recorder.getIntervalHistogram(intervalHistogram);
/** * Reset any value counts accumulated thus far. */ @Override public synchronized void reset() { // the currently inactive histogram is reset each time we flip. So flipping twice resets both: performIntervalSample(); performIntervalSample(); }
void recordValue(final long duration) { recorder.recordValue(duration); }
@Override public void run() { final long resolutionNsec = (long) (config.resolutionInMs() * 1000L * 1000L); try { long shortestObservedDeltaTimeNsec = Long.MAX_VALUE; while (doRun) { final long timeBeforeMeasurement = System.nanoTime(); if (config.resolutionInMs() != 0) { TimeUnit.NANOSECONDS.sleep(resolutionNsec); if (config.allocateObjects()) { // Allocate an object to make sure potential allocation stalls are measured. lastSleepTimeObj = new Long(timeBeforeMeasurement); } } final long timeAfterMeasurement = System.nanoTime(); final long deltaTimeNsec = timeAfterMeasurement - timeBeforeMeasurement; if (deltaTimeNsec < shortestObservedDeltaTimeNsec) { shortestObservedDeltaTimeNsec = deltaTimeNsec; } long hiccupTimeNsec = deltaTimeNsec - shortestObservedDeltaTimeNsec; recorder.recordValueWithExpectedInterval(hiccupTimeNsec, resolutionNsec); } } catch (InterruptedException e) { logger.debug("# HiccupRecorder interrupted/terminating..."); } } }
/** * Place a copy of the value counts accumulated since accumulated (since the last interval histogram * was taken) into {@code targetHistogram}. * * Calling {@link SingleWriterRecorder#getIntervalHistogramInto getIntervalHistogramInto()} will reset * the value counts, and start accumulating value counts for the next interval. * * @param targetHistogram the histogram into which the interval histogram's data should be copied */ public synchronized void getIntervalHistogramInto(Histogram targetHistogram) { performIntervalSample(); inactiveHistogram.copyInto(targetHistogram); }
return getIntervalHistogram(histogramToRecycle, true);
boolean enforeContainingInstance) { validateFitAsReplacementHistogram(histogramToRecycle, enforeContainingInstance); inactiveHistogram = (InternalHistogram) histogramToRecycle; performIntervalSample(); Histogram sampledHistogram = inactiveHistogram;
/** * Reset any value counts accumulated thus far. */ @Override public synchronized void reset() { // the currently inactive histogram is reset each time we flip. So flipping twice resets both: performIntervalSample(); performIntervalSample(); }
/** * Get a new instance of an interval histogram, which will include a stable, consistent view of all value * counts accumulated since the last interval histogram was taken. * <p> * Calling {@link SingleWriterRecorder#getIntervalHistogram()} will reset * the value counts, and start accumulating value counts for the next interval. * * @return a histogram containing the value counts accumulated since the last interval histogram was taken. */ public synchronized Histogram getIntervalHistogram() { return getIntervalHistogram(null); }
/** * Place a copy of the value counts accumulated since accumulated (since the last interval histogram * was taken) into {@code targetHistogram}. * * Calling {@link SingleWriterRecorder#getIntervalHistogramInto getIntervalHistogramInto()} will reset * the value counts, and start accumulating value counts for the next interval. * * @param targetHistogram the histogram into which the interval histogram's data should be copied */ public synchronized void getIntervalHistogramInto(Histogram targetHistogram) { performIntervalSample(); inactiveHistogram.copyInto(targetHistogram); }
Histogram getTimings() { histogram = recorder.getIntervalHistogram(histogram); return histogram; } }
return getIntervalHistogram(histogramToRecycle, true);