Search in sources :

Example 1 with SimplePauseDetector

use of org.LatencyUtils.SimplePauseDetector in project LatencyUtils by LatencyUtils.

the class LatencyLoggingDemo method main.

public static void main(final String[] args) throws FileNotFoundException {
    // Knowing that we're using a SimplePauseDetector, set it to verbose so that the user can see
    // the pause detection messages:
    ((SimplePauseDetector) latencyStats.getPauseDetector()).setVerbose(true);
    final ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(2);
    // Record latencies on a "regular" basis. This will tend to record semi-reliably at
    // each interval as long as the JVM doesn't stall.
    executor.scheduleWithFixedDelay(new Recorder(), RECORDING_INTERVAL, RECORDING_INTERVAL, TimeUnit.NANOSECONDS);
    histogramLogWriter = new HistogramLogWriter(fillInPidAndDate(defaultLogFileName));
    histogramLogWriter.outputComment("[Logged with LatencyLoggingDemo]");
    histogramLogWriter.outputLogFormatVersion();
    reportingStartTime = System.currentTimeMillis();
    // Force an interval sample right at the reporting start time (to start samples here):
    latencyStats.getIntervalHistogram();
    histogramLogWriter.outputStartTime(reportingStartTime);
    histogramLogWriter.outputLegend();
    // Regularly report on observations into log file:
    executor.scheduleWithFixedDelay(new Reporter(), REPORTING_INTERVAL, REPORTING_INTERVAL, TimeUnit.NANOSECONDS);
    while (true) ;
}
Also used : HistogramLogWriter(org.HdrHistogram.HistogramLogWriter) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) SimplePauseDetector(org.LatencyUtils.SimplePauseDetector)

Example 2 with SimplePauseDetector

use of org.LatencyUtils.SimplePauseDetector in project LatencyUtils by LatencyUtils.

the class LatencyComparativeLoggingDemo method main.

public static void main(final String[] args) throws FileNotFoundException {
    // Knowing that we're using a SimplePauseDetector, set it to verbose so that the user can see
    // the pause detection messages:
    ((SimplePauseDetector) latencyStats.getPauseDetector()).setVerbose(true);
    final ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(2);
    // Record latencies on a "regular" basis. This will tend to record semi-reliably at
    // each interval as long as the JVM doesn't stall.
    executor.scheduleWithFixedDelay(new Recorder(), RECORDING_INTERVAL, RECORDING_INTERVAL, TimeUnit.NANOSECONDS);
    histogramLogWriter = new HistogramLogWriter(fillInPidAndDate(defaultLogFileName));
    histogramLogWriter.outputComment("[Logged with LatencyLoggingDemo]");
    histogramLogWriter.outputLogFormatVersion();
    uncorrectedHistogramLogWriter = new HistogramLogWriter(fillInPidAndDate(defaultUncorrectedLogFileName));
    uncorrectedHistogramLogWriter.outputComment("[Logged with LatencyLoggingDemo (Raw)]");
    uncorrectedHistogramLogWriter.outputLogFormatVersion();
    reportingStartTime = System.currentTimeMillis();
    // Force an interval sample right at the reporting start time (to start samples here):
    latencyStats.getIntervalHistogram();
    histogramLogWriter.outputStartTime(reportingStartTime);
    histogramLogWriter.outputLegend();
    uncorrectedHistogramLogWriter.outputStartTime(reportingStartTime);
    uncorrectedHistogramLogWriter.outputLegend();
    // Regularly report on observations into log file:
    executor.scheduleWithFixedDelay(new Reporter(), REPORTING_INTERVAL, REPORTING_INTERVAL, TimeUnit.NANOSECONDS);
    while (true) ;
}
Also used : HistogramLogWriter(org.HdrHistogram.HistogramLogWriter) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) SimplePauseDetector(org.LatencyUtils.SimplePauseDetector)

Example 3 with SimplePauseDetector

use of org.LatencyUtils.SimplePauseDetector in project LatencyUtils by LatencyUtils.

the class LatencyStatsDemo method main.

public static void main(final String[] args) {
    // Knowing that we're using a SimplePauseDetector, set it to verbose so that the user can see
    // the pause detection messages:
    ((SimplePauseDetector) latencyStats.getPauseDetector()).setVerbose(true);
    final ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(2);
    // Record latencies on a "regular" basis. This will tend to record semi-reliably at
    // each interval as long as the JVM doesn't stall.
    executor.scheduleWithFixedDelay(new Recorder(), RECORDING_INTERVAL, RECORDING_INTERVAL, TimeUnit.NANOSECONDS);
    // Regularly report o observations:
    executor.scheduleWithFixedDelay(new Reporter(), REPORTING_INTERVAL, REPORTING_INTERVAL, TimeUnit.NANOSECONDS);
    while (true) ;
}
Also used : ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) SimplePauseDetector(org.LatencyUtils.SimplePauseDetector)

Aggregations

ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)3 SimplePauseDetector (org.LatencyUtils.SimplePauseDetector)3 HistogramLogWriter (org.HdrHistogram.HistogramLogWriter)2