public long getCompleted() { return histo.getTotalCount(); }
@Override public synchronized long getTotalCount() { return super.getTotalCount(); }
@Override public int size() { return (int) histogram.getTotalCount(); }
private Map<CommandLatencyId, CommandMetrics> getMetrics(Map<CommandLatencyId, Latencies> latencyMetrics) { Map<CommandLatencyId, CommandMetrics> result = new TreeMap<>(); for (Map.Entry<CommandLatencyId, Latencies> entry : latencyMetrics.entrySet()) { Latencies latencies = entry.getValue(); Histogram firstResponse = latencies.getFirstResponseHistogram(); Histogram completion = latencies.getCompletionHistogram(); if (firstResponse.getTotalCount() == 0 && completion.getTotalCount() == 0) { continue; } CommandLatency firstResponseLatency = getMetric(firstResponse); CommandLatency completionLatency = getMetric(completion); CommandMetrics metrics = new CommandMetrics(firstResponse.getTotalCount(), options.targetUnit(), firstResponseLatency, completionLatency); result.put(entry.getKey(), metrics); } return result; }
@Override public long[] getValues() { long[] vals = new long[(int) histogram.getTotalCount()]; int i = 0; for (HistogramIterationValue value : histogram.recordedValues()) { long val = value.getValueIteratedTo(); for (int j = 0; j < value.getCountAddedInThisIterationStep(); j++) { vals[i] = val; i++; } } if (i != vals.length) { throw new IllegalStateException( "Total count was " + histogram.getTotalCount() + " but iterating values produced " + vals.length); } return vals; }
/** * 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)) + "]"; }
((intervalHistogram.getEndTimeStamp() / 1000.0) - logReader.getStartTimeSec()), ((Histogram) intervalHistogram).getTotalCount(), ((Histogram) intervalHistogram).getValueAtPercentile(50.0) / config.outputValueUnitRatio, ((Histogram) intervalHistogram).getValueAtPercentile(90.0) / config.outputValueUnitRatio, ((Histogram) intervalHistogram).getMaxValue() / config.outputValueUnitRatio, accumulatedRegularHistogram.getTotalCount(), accumulatedRegularHistogram.getValueAtPercentile(50.0) / config.outputValueUnitRatio, accumulatedRegularHistogram.getValueAtPercentile(90.0) / config.outputValueUnitRatio, ((intervalHistogram.getEndTimeStamp() / 1000.0) - logReader.getStartTimeSec()), ((Histogram) movingWindowSumHistogram).getTotalCount(), ((Histogram) movingWindowSumHistogram).getValueAtPercentile(config.movingWindowPercentileToReport) / config.outputValueUnitRatio, ((Histogram) movingWindowSumHistogram).getMaxValue() / config.outputValueUnitRatio
exporter.write(getName(), "Operations", totalHistogram.getTotalCount()); exporter.write(getName(), "AverageLatency(us)", totalHistogram.getMean()); exporter.write(getName(), "MinLatency(us)", totalHistogram.getMinValue());
/** * Returns the request latency at a given percentile. * * @param host the host (if this is relevant in the way percentiles are categorized). * @param statement the statement (if this is relevant in the way percentiles are categorized). * @param exception the exception (if this is relevant in the way percentiles are categorized). * @param percentile the percentile (for example, {@code 99.0} for the 99th percentile). * @return the latency (in milliseconds) at the given percentile, or a negative value if it's not * available yet. * @see #computeKey(Host, Statement, Exception) */ public long getLatencyAtPercentile( Host host, Statement statement, Exception exception, double percentile) { checkArgument( percentile >= 0.0 && percentile < 100, "percentile must be between 0.0 and 100 (was %s)", percentile); Histogram histogram = getLastIntervalHistogram(host, statement, exception); if (histogram == null || histogram.getTotalCount() < minRecordedValues) return -1; return histogram.getValueAtPercentile(percentile); }
@UserAggregationResult public List<Number> result() { long totalCount = values != null ? values.getTotalCount() : doubles.getTotalCount(); boolean empty = totalCount == 0; List<Number> result = new ArrayList<>(percentiles.size()); for (Double percentile : percentiles) { if (percentile == null || empty) { result.add(null); } else { if (values != null) { result.add(values.getValueAtPercentile(percentile * 100D)); } else { result.add(doubles.getValueAtPercentile(percentile * 100D)); } } } return result; } }
p100 = (int) underlying.getValueAtPercentile(100); totalCount = underlying.getTotalCount();
@UserAggregationResult public Map<String,Number> result() { long totalCount = values != null ? values.getTotalCount() : doubles.getTotalCount(); boolean empty = totalCount == 0; Map<String,Number> result = new LinkedHashMap<>(percentiles.size()+6); result.put("min",values != null ? (Number)values.getMinValue() : (Number)doubles.getMinValue()); result.put("minNonZero",values != null ? (Number)values.getMinNonZeroValue() : (Number)doubles.getMinNonZeroValue()); result.put("max",values != null ? (Number)values.getMaxValue() : (Number)doubles.getMaxValue()); result.put("total",totalCount); result.put("mean",values != null ? values.getMean() : doubles.getMean()); result.put("stdev",values != null ? values.getStdDeviation() : doubles.getStdDeviation()); for (Double percentile : percentiles) { if (percentile != null && !empty) { if (values != null) { result.put(percentile.toString(), values.getValueAtPercentile(percentile * 100D)); } else { result.put(percentile.toString(), doubles.getValueAtPercentile(percentile * 100D)); } } } return result; } }
@Override public synchronized long getTotalCount() { return super.getTotalCount(); }
public static Snapshot getSnapshot(Histogram histogram, Function<Histogram, Snapshot> snapshotTaker) { if (histogram.getTotalCount() > 0) { return snapshotTaker.apply(histogram); } else { return EmptySnapshot.INSTANCE; } }
public static Snapshot getSnapshot(Histogram histogram, Function<Histogram, Snapshot> snapshotTaker) { if (histogram.getTotalCount() > 0) { return snapshotTaker.apply(histogram); } else { return EmptySnapshot.INSTANCE; } }
public static void reset(Histogram histogram) { if (histogram.getTotalCount() > 0) { histogram.reset(); } }
public static void addSecondToFirst(Histogram first, Histogram second) { if (second.getTotalCount() > 0) { first.add(second); } }
public static void reset(Histogram histogram) { if (histogram.getTotalCount() > 0) { histogram.reset(); } }
public void updateStats() { topicLoadHistogram = topicLoadTimeRecorder.getIntervalHistogram(topicLoadHistogram); this.elapsedIntervalMs = (TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - topicLoadRecordStartTime); topicLoadRecordStartTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); this.meanTopicLoadMs = topicLoadHistogram.getMean(); this.medianTopicLoadMs = topicLoadHistogram.getValueAtPercentile(50); this.topicLoad95Ms = topicLoadHistogram.getValueAtPercentile(95); this.topicLoad99Ms = topicLoadHistogram.getValueAtPercentile(99); this.topicLoad999Ms = topicLoadHistogram.getValueAtPercentile(99.9); this.topicsLoad9999Ms = topicLoadHistogram.getValueAtPercentile(99.99); this.topicLoadCounts = topicLoadHistogram.getTotalCount(); }
private void readsHistogram(final int expectedCount) throws IOException { reset(logHandler); assertEquals(1, reader.read(logHandler)); verify(logHandler, times(1)).onHistogram(anyLong(), eq(NAME), histogramCaptor.capture()); assertEquals("Histogram returns unexpected count", expectedCount, histogram().getTotalCount()); }