private static void addBinIfNotEmpty(SimpleHistogramDataSetContainer histogramDataSet, SimpleHistogramBin bin) { if (bin != null && bin.getItemCount() > 0) { histogramDataSet.addBin(bin); } } }
/** * Returns the y-value (as a double primitive) for an item within a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The y-value. * * @see #getAdjustForBinSize() */ @Override public double getYValue(int series, int item) { SimpleHistogramBin bin = (SimpleHistogramBin) this.bins.get(item); if (this.adjustForBinSize) { return bin.getItemCount() / (bin.getUpperBound() - bin.getLowerBound()); } else { return bin.getItemCount(); } }
/** * Returns the y-value (as a double primitive) for an item within a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The y-value. * * @see #getAdjustForBinSize() */ public double getYValue(int series, int item) { SimpleHistogramBin bin = (SimpleHistogramBin) this.bins.get(item); if (this.adjustForBinSize) { return bin.getItemCount() / (bin.getUpperBound() - bin.getLowerBound()); } else { return bin.getItemCount(); } }
/** * Adds an observation to the dataset (by incrementing the item count for * the appropriate bin). A runtime exception is thrown if the value does * not fit into any bin. * * @param value the value. * @param notify send {@link DatasetChangeEvent} to listeners? */ public void addObservation(double value, boolean notify) { boolean placed = false; Iterator iterator = this.bins.iterator(); while (iterator.hasNext() && !placed) { SimpleHistogramBin bin = (SimpleHistogramBin) iterator.next(); if (bin.accepts(value)) { bin.setItemCount(bin.getItemCount() + 1); placed = true; } } if (!placed) { throw new RuntimeException("No bin."); } if (notify) { notifyListeners(new DatasetChangeEvent(this, this)); } }
/** * Adds an observation to the dataset (by incrementing the item count for * the appropriate bin). A runtime exception is thrown if the value does * not fit into any bin. * * @param value the value. * @param notify send {@link DatasetChangeEvent} to listeners? */ public void addObservation(double value, boolean notify) { boolean placed = false; Iterator iterator = this.bins.iterator(); while (iterator.hasNext() && !placed) { SimpleHistogramBin bin = (SimpleHistogramBin) iterator.next(); if (bin.accepts(value)) { bin.setItemCount(bin.getItemCount() + 1); placed = true; } } if (!placed) { throw new RuntimeException("No bin."); } if (notify) { notifyListeners(new DatasetChangeEvent(this, this)); } }
private static SimpleHistogramDataSetContainer calcSingleProbeDataSet(LatencyDistributionResult probeData, long accuracy, double scalingPercentile) { SimpleHistogramDataSetContainer histogramDataSet = new SimpleHistogramDataSetContainer("key"); histogramDataSet.setAdjustForBinSize(false); LinearHistogram histogram = probeData.getHistogram(); int histogramStep = histogram.getStep(); int lowerBound = 0; SimpleHistogramBin bin = new SimpleHistogramBin(0, accuracy, true, false); for (int values : histogram.getBuckets()) { if (lowerBound % accuracy == 0 && lowerBound > 0) { addBinIfNotEmpty(histogramDataSet, bin); bin = new SimpleHistogramBin(lowerBound, lowerBound + accuracy, true, false); } if (values > 0) { bin.setItemCount(bin.getItemCount() + values); } lowerBound += histogramStep; } addBinIfNotEmpty(histogramDataSet, bin); histogramDataSet.setAutoScaleValue(histogram.getPercentile(scalingPercentile).getBucket()); return histogramDataSet; }