/** * Output an interval histogram, with the given timestamp information, and the [optional] tag * associated with the histogram. (note that the specified timestamp information will be used, * and the timestamp information in the actual histogram will be ignored). * The max value in the histogram will be reported scaled down by a default maxValueUnitRatio of * 1,000,000 (which is the msec : nsec ratio). Caller should use the direct form specifying * maxValueUnitRatio some other ratio is needed for the max value output. * @param startTimeStampSec The start timestamp to log with the interval histogram, in seconds. * @param endTimeStampSec The end timestamp to log with the interval histogram, in seconds. * @param histogram The interval histogram to log. */ public void outputIntervalHistogram(final double startTimeStampSec, final double endTimeStampSec, final EncodableHistogram histogram) { outputIntervalHistogram(startTimeStampSec, endTimeStampSec, histogram, 1000000.0); }
public OneMeasurementHdrHistogram(String name, Properties props) { super(name); percentiles = getPercentileValues(props.getProperty(PERCENTILES_PROPERTY, PERCENTILES_PROPERTY_DEFAULT)); verbose = Boolean.valueOf(props.getProperty(VERBOSE_PROPERTY, String.valueOf(false))); boolean shouldLog = Boolean.parseBoolean(props.getProperty("hdrhistogram.fileoutput", "false")); if (!shouldLog) { log = null; histogramLogWriter = null; } else { try { final String hdrOutputFilename = props.getProperty("hdrhistogram.output.path", "") + name + ".hdr"; log = new PrintStream(new FileOutputStream(hdrOutputFilename), false); } catch (FileNotFoundException e) { throw new RuntimeException("Failed to open hdr histogram output file", e); } histogramLogWriter = new HistogramLogWriter(log); histogramLogWriter.outputComment("[Logging for: " + name + "]"); histogramLogWriter.outputLogFormatVersion(); long now = System.currentTimeMillis(); histogramLogWriter.outputStartTime(now); histogramLogWriter.setBaseTime(now); histogramLogWriter.outputLegend(); } histogram = new Recorder(3); }
HistogramLogWriter writer = new HistogramLogWriter(outputFile); writer.outputComment("[Latency histograms for " + getBaseName(outputFile) + ']'); writer.outputLogFormatVersion(); writer.outputLegend(); writer.outputIntervalHistogram(merged);
/** * Output a log format version to the log. */ public void outputLogFormatVersion() { outputComment("[Histogram log format version " + HISTOGRAM_LOG_FORMAT_VERSION +"]"); }
HistogramLogWriter histogramLogWriter = new HistogramLogWriter(histogramLog); histogramLogWriter.outputLogFormatVersion(); histogramLogWriter.outputLegend(); dec.format(reportHistogram.getValueAtPercentile(99.99) / 1000.0)); histogramLogWriter.outputIntervalHistogram(reportHistogram); reportHistogram.reset();
/** * Output a log format version to the log. */ public void outputLogFormatVersion() { outputComment("[Histogram log format version " + HISTOGRAM_LOG_FORMAT_VERSION +"]"); }
static HistogramLogWriter createHistogramLogWriter(String testId, String probeName, long baseTime) { try { File latencyFile = getLatencyFile(testId, probeName); HistogramLogWriter histogramLogWriter = new HistogramLogWriter(latencyFile); histogramLogWriter.setBaseTime(baseTime); histogramLogWriter.outputStartTime(System.currentTimeMillis()); 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); } }
HistogramLogWriter histogramLogWriter = new HistogramLogWriter(histogramLog); histogramLogWriter.outputLogFormatVersion(); histogramLogWriter.outputLegend(); dec.format(reportHistogram.getMaxValue() / 1000.0)); histogramLogWriter.outputIntervalHistogram(reportHistogram); reportHistogram.reset();
/** * Output an interval histogram, using the start/end timestamp indicated in the histogram, * and the [optional] tag associated with the histogram. * The histogram start and end timestamps are assumed to be in msec units. Logging will be * in seconds, realtive by a base time (if set via {@link org.HdrHistogram.HistogramLogWriter#setBaseTime}). * The default base time is 0. * <p> * By covention, histogram start/end time are generally stamped with absolute times in msec * since the epoch. For logging with absolute time stamps, the base time would remain zero. For * logging with relative time stamps (time since a start point), the base time should be set * with {@link org.HdrHistogram.HistogramLogWriter#setBaseTime}. * <p> * The max value in the histogram will be reported scaled down by a default maxValueUnitRatio of * 1,000,000 (which is the msec : nsec ratio). Caller should use the direct form specifying * maxValueUnitRatio if some other ratio is needed for the max value output. * @param histogram The interval histogram to log. */ public void outputIntervalHistogram(final EncodableHistogram histogram) { outputIntervalHistogram((histogram.getStartTimeStamp() - baseTime)/1000.0, (histogram.getEndTimeStamp() - baseTime)/1000.0, histogram); }
/** * By convention, it is typical for the logging application * to use a comment to indicate the logging application at the head * of the log, followed by the log format version, a startLogging time, * and a legend (in that order). */ public void startLogging() { try { logStream = new PrintStream(logfile); writer = new HistogramLogWriter(logStream); writer.outputComment("logging histograms for session " + sessionName); writer.outputLogFormatVersion(); long currentTimeMillis = System.currentTimeMillis(); writer.outputStartTime(currentTimeMillis); writer.setBaseTime(currentTimeMillis); writer.outputLegend(); } catch (FileNotFoundException e) { throw new RuntimeException("Error while starting histogram log writer", e); } this.executor = new PeriodicRunnable<HistoIntervalLogger>(this.getInterval(),this); executor.startDaemonThread(); }
/** * This is called periodically from the StatusThread. There's a single * StatusThread per Client process. We optionally serialize the interval to * log on this opportunity. * * @see com.yahoo.ycsb.measurements.OneMeasurement#getSummary() */ @Override public String getSummary() { Histogram intervalHistogram = getIntervalHistogramAndAccumulate(); // we use the summary interval as the histogram file interval. if (histogramLogWriter != null) { histogramLogWriter.outputIntervalHistogram(intervalHistogram); } DecimalFormat d = new DecimalFormat("#.##"); return "[" + getName() + ": Count=" + intervalHistogram.getTotalCount() + ", Max=" + intervalHistogram.getMaxValue() + ", Min=" + intervalHistogram.getMinValue() + ", Avg=" + d.format(intervalHistogram.getMean()) + ", 90=" + d.format(intervalHistogram.getValueAtPercentile(90)) + ", 99=" + d.format(intervalHistogram.getValueAtPercentile(99)) + ", 99.9=" + d.format(intervalHistogram.getValueAtPercentile(99.9)) + ", 99.99=" + d.format(intervalHistogram.getValueAtPercentile(99.99)) + "]"; }
histogramLogWriter.outputIntervalHistogram(intervalHistogram);
/** * Write the last results via the log writer. * @param writer the log writer to use */ public void write(HistogramLogWriter writer) { writer.outputIntervalHistogram(lastHistogram); }
/** * Output an interval histogram, with the given timestamp information, and the [optional] tag * associated with the histogram. (note that the specified timestamp information will be used, * and the timestamp information in the actual histogram will be ignored). * The max value in the histogram will be reported scaled down by a default maxValueUnitRatio of * 1,000,000 (which is the msec : nsec ratio). Caller should use the direct form specifying * maxValueUnitRatio some other ratio is needed for the max value output. * @param startTimeStampSec The start timestamp to log with the interval histogram, in seconds. * @param endTimeStampSec The end timestamp to log with the interval histogram, in seconds. * @param histogram The interval histogram to log. */ public void outputIntervalHistogram(final double startTimeStampSec, final double endTimeStampSec, final EncodableHistogram histogram) { outputIntervalHistogram(startTimeStampSec, endTimeStampSec, histogram, 1000000.0); }
@Override public void run() { for (WriterTarget target : targets) { writer.outputIntervalHistogram(target.histoProvider.getNextHdrDeltaHistogram()); } lastRunTime = System.currentTimeMillis(); }
/** * Output an interval histogram, using the start/end timestamp indicated in the histogram, * and the [optional] tag associated with the histogram. * The histogram start and end timestamps are assumed to be in msec units. Logging will be * in seconds, realtive by a base time (if set via {@link org.HdrHistogram.HistogramLogWriter#setBaseTime}). * The default base time is 0. * <p> * By covention, histogram start/end time are generally stamped with absolute times in msec * since the epoch. For logging with absolute time stamps, the base time would remain zero. For * logging with relative time stamps (time since a start point), the base time should be set * with {@link org.HdrHistogram.HistogramLogWriter#setBaseTime}. * <p> * The max value in the histogram will be reported scaled down by a default maxValueUnitRatio of * 1,000,000 (which is the msec : nsec ratio). Caller should use the direct form specifying * maxValueUnitRatio if some other ratio is needed for the max value output. * @param histogram The interval histogram to log. */ public void outputIntervalHistogram(final EncodableHistogram histogram) { outputIntervalHistogram((histogram.getStartTimeStamp() - baseTime)/1000.0, (histogram.getEndTimeStamp() - baseTime)/1000.0, histogram); }
void writeStatsToFile(long epochTime, String timestamp) { performanceLogWriter.write( epochTime, timestamp, totalOperationCount, intervalOperationCount, intervalThroughput, 0, 0); for (Map.Entry<String, Histogram> histogramEntry : intervalHistogramMap.entrySet()) { String probeName = histogramEntry.getKey(); HistogramLogWriter histogramLogWriter = histogramLogWriterMap.get(probeName); if (histogramLogWriter == null) { histogramLogWriter = createHistogramLogWriter( testContainer.getTestCase().getId(), probeName, testStartedTimestamp); histogramLogWriterMap.put(probeName, histogramLogWriter); } Histogram intervalHistogram = histogramEntry.getValue(); intervalHistogram.setStartTimeStamp(previousWriteToFile); intervalHistogram.setEndTimeStamp(epochTime); histogramLogWriter.outputIntervalHistogram(intervalHistogram); } previousWriteToFile = epochTime; }
/** * @return a copy of the accumulated state since the reservoir last had a snapshot */ private synchronized Histogram getDataSinceLastSnapshotAndUpdate() { intervalHistogram = recorder.getIntervalHistogram(intervalHistogram); long intervalHistogramStartTime = intervalHistogramEndTime; intervalHistogramEndTime = System.currentTimeMillis(); intervalHistogram.setTag(metricName); intervalHistogram.setStartTimeStamp(intervalHistogramStartTime); intervalHistogram.setEndTimeStamp(intervalHistogramEndTime); lastHistogram = intervalHistogram.copy(); lastHistogram.setTag(metricName); if (writer!=null) { writer.outputIntervalHistogram(lastHistogram); } return lastHistogram; }