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

The following examples show how to use org.HdrHistogram.HistogramLogWriter#close() . 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: PersistedHistogram.java    From benchmarks with Apache License 2.0 6 votes vote down vote up
static Path saveToFile(final Histogram histogram, final Path file)
    throws FileNotFoundException
{
    final HistogramLogWriter logWriter = new HistogramLogWriter(file.toFile());
    try
    {
        logWriter.outputIntervalHistogram(
            histogram.getStartTimeStamp() / 1000.0,
            histogram.getEndTimeStamp() / 1000.0,
            histogram,
            1.0);
    }
    finally
    {
        logWriter.close();
    }

    return file;
}
 
Example 2
Source File: ResultsAggregatorTest.java    From benchmarks with Apache License 2.0 5 votes vote down vote up
private void saveToDisc(final String fileName, final Histogram histogram) throws FileNotFoundException
{
    final HistogramLogWriter logWriter = new HistogramLogWriter(tempDir.resolve(fileName).toFile());
    try
    {
        logWriter.outputIntervalHistogram(
            histogram.getStartTimeStamp() / 1000.0, histogram.getEndTimeStamp() / 1000.0, histogram, 1);
    }
    finally
    {
        logWriter.close();
    }
}
 
Example 3
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);
  }
}