Java Code Examples for org.HdrHistogram.HistogramLogWriter#setBaseTime()

The following examples show how to use org.HdrHistogram.HistogramLogWriter#setBaseTime() . 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: HlogReporter.java    From Rainfall-core with Apache License 2.0 5 votes vote down vote up
@Override
public void summarize(final StatisticsHolder<E> statisticsHolder) {
  // dump raw histograms as hlog files
  long startTime = ManagementFactory.getRuntimeMXBean().getStartTime();
  long endTime = System.currentTimeMillis();
  try {
    Enum<E>[] results = statisticsHolder.getResultsReported();
    for (Enum<E> result : results) {
      Histogram rawHistogram = statisticsHolder.fetchHistogram(result);
      rawHistogram.setStartTimeStamp(startTime);
      rawHistogram.setEndTimeStamp(endTime);

      File hlogFile = new File(this.basedir + File.separatorChar + buildHlogFilename(result.name()));
      hlogFile.getParentFile().mkdirs();
      HistogramLogWriter writer = new HistogramLogWriter(new PrintStream(hlogFile));
      writer.setBaseTime(startTime);

      writer.outputLogFormatVersion();
      writer.outputBaseTime(writer.getBaseTime());
      writer.outputLegend();
      writer.outputIntervalHistogram(rawHistogram);

      writer.close();
    }
  } catch (Exception e) {
    throw new RuntimeException("Can not report to hlog", e);
  }
}
 
Example 2
Source File: TestPerformanceTracker.java    From hazelcast-simulator with Apache License 2.0 5 votes vote down vote up
HistogramLogWriter createHistogramLogWriter(String probeName) {
    String testId = testContainer.getTestCase().getId();
    try {
        File latencyFile = getLatencyFile(testId, probeName);
        HistogramLogWriter histogramLogWriter = new HistogramLogWriter(latencyFile);
        histogramLogWriter.setBaseTime(testContainer.getRunStartedMillis());
        histogramLogWriter.outputStartTime(testContainer.getRunStartedMillis());
        histogramLogWriter.outputComment("[Latency histograms for " + testId + '.' + probeName + ']');
        histogramLogWriter.outputLogFormatVersion();
        histogramLogWriter.outputLegend();
        return histogramLogWriter;
    } catch (IOException e) {
        throw new TestException("Could not initialize HistogramLogWriter for test " + testId, e);
    }
}