Esempio n. 1
0
        /**
         * Get the computed mean value of all recorded values in the histogram
         *
         * @return the mean value (in value units) of the histogram data
         */
        public double getMean()
        {
            recordedValuesIterator.reset();
            long totalValue = 0;

            while (recordedValuesIterator.hasNext())
            {
                HistogramIterationValue iterationValue = recordedValuesIterator.next();
                totalValue = iterationValue.getTotalValueToThisValue();
            }
            return((totalValue * 1.0) / getTotalCount());
        }
Esempio n. 2
0
        /**
         * Get the highest recorded value level in the histogram
         *
         * @return the Max value recorded in the histogram
         */
        public long getMaxValue()
        {
            recordedValuesIterator.reset();
            long max = 0;

            while (recordedValuesIterator.hasNext())
            {
                HistogramIterationValue iterationValue = recordedValuesIterator.next();
                max = iterationValue.getValueIteratedTo();
            }
            return(histogram.lowestEquivalentValue(max));
        }
Esempio n. 3
0
        /**
         * Get the lowest recorded value level in the histogram
         *
         * @return the Min value recorded in the histogram
         */
        public long getMinValue()
        {
            recordedValuesIterator.reset();
            long min = 0;

            if (recordedValuesIterator.hasNext())
            {
                HistogramIterationValue iterationValue = recordedValuesIterator.next();
                min = iterationValue.getValueIteratedTo();
            }
            return(histogram.lowestEquivalentValue(min));
        }
        public void WriteValue(HistogramIterationValue iterationValue)
        {
            var scaledValue = iterationValue.ValueIteratedTo / _outputValueUnitScalingRatio;
            var percentile  = iterationValue.PercentileLevelIteratedTo / 100.0D;

            if (iterationValue.IsLastValue())
            {
                _printStream.Write(_lastLinePercentileFormatString, scaledValue, percentile, iterationValue.TotalCountToThisValue);
            }
            else
            {
                _printStream.Write(_percentileFormatString, scaledValue, percentile, iterationValue.TotalCountToThisValue, 1 / (1.0D - percentile));
            }
        }
Esempio n. 5
0
        /**
         * Get the computed standard deviation of all recorded values in the histogram
         *
         * @return the standard deviation (in value units) of the histogram data
         */
        public double getStdDeviation()
        {
            double mean = getMean();
            double geometric_deviation_total = 0.0;

            recordedValuesIterator.reset();
            while (recordedValuesIterator.hasNext())
            {
                HistogramIterationValue iterationValue = recordedValuesIterator.next();
                Double deviation = (histogram.medianEquivalentValue(iterationValue.getValueIteratedTo()) * 1.0) - mean;
                geometric_deviation_total += (deviation * deviation) * iterationValue.getCountAddedInThisIterationStep();
            }
            double std_deviation = Math.Sqrt(geometric_deviation_total / getTotalCount());

            return(std_deviation);
        }
Esempio n. 6
0
        /**
         * Produce textual representation of the value distribution of histogram data by percentile. The distribution is
         * output with exponentially increasing resolution, with each exponentially decreasing half-distance containing
         * <i>dumpTicksPerHalf</i> percentile reporting tick points.
         *
         * @param printStream    Stream into which the distribution will be output
         * <p>
         * @param percentileTicksPerHalfDistance  The number of reporting points per exponentially decreasing half-distance
         * <p>
         * @param outputValueUnitScalingRatio    The scaling factor by which to divide histogram recorded values units in
         *                                     output
         * @param useCsvFormat  Output in CSV format if true. Otherwise use plain text form.
         */
        public void outputPercentileDistribution(/*final*/ TextWriter /*PrintStream*/ printStream,
                                                 /*final*/ int percentileTicksPerHalfDistance = 5,
                                                 /*final*/ Double outputValueUnitScalingRatio = 1000.0,
                                                 bool useCsvFormat = false)
        {
            if (useCsvFormat)
            {
                printStream.Write("\"Value\",\"Percentile\",\"TotalCount\",\"1/(1-Percentile)\"\n");
            }
            else
            {
                printStream.Write("{0,12} {1,14} {2,10} {3,14}\n\n", "Value", "Percentile", "TotalCount", "1/(1-Percentile)");
            }

            PercentileIterator iterator = percentileIterator;

            iterator.reset(percentileTicksPerHalfDistance);

            String percentileFormatString;
            String lastLinePercentileFormatString;

            if (useCsvFormat)
            {
                percentileFormatString         = "{0:F" + histogram.numberOfSignificantValueDigits + "},{1:F12},{2},{3:F2}\n";
                lastLinePercentileFormatString = "{0:F" + histogram.numberOfSignificantValueDigits + "},{1:F12},{2},Infinity\n";
            }
            else
            {
                percentileFormatString         = "{0,12:F" + histogram.numberOfSignificantValueDigits + "}" + " {1,2:F12} {2,10} {3,14:F2}\n";
                lastLinePercentileFormatString = "{0,12:F" + histogram.numberOfSignificantValueDigits + "} {1,2:F12} {2,10}\n";
            }

            try
            {
                while (iterator.hasNext())
                {
                    HistogramIterationValue iterationValue = iterator.next();
                    if (iterationValue.getPercentileLevelIteratedTo() != 100.0D)
                    {
                        printStream.Write(percentileFormatString,
                                          iterationValue.getValueIteratedTo() / outputValueUnitScalingRatio,
                                          iterationValue.getPercentileLevelIteratedTo() / 100.0D,
                                          iterationValue.getTotalCountToThisValue(),
                                          1 / (1.0D - (iterationValue.getPercentileLevelIteratedTo() / 100.0D)));
                    }
                    else
                    {
                        printStream.Write(lastLinePercentileFormatString,
                                          iterationValue.getValueIteratedTo() / outputValueUnitScalingRatio,
                                          iterationValue.getPercentileLevelIteratedTo() / 100.0D,
                                          iterationValue.getTotalCountToThisValue());
                    }
                }

                if (!useCsvFormat)
                {
                    // Calculate and output mean and std. deviation.
                    // Note: mean/std. deviation numbers are very often completely irrelevant when
                    // data is extremely non-normal in distribution (e.g. in cases of strong multi-modal
                    // response time distribution associated with GC pauses). However, reporting these numbers
                    // can be very useful for contrasting with the detailed percentile distribution
                    // reported by outputPercentileDistribution(). It is not at all surprising to find
                    // percentile distributions where results fall many tens or even hundreds of standard
                    // deviations away from the mean - such results simply indicate that the data sampled
                    // exhibits a very non-normal distribution, highlighting situations for which the std.
                    // deviation metric is a useless indicator.

                    double mean          = getMean() / outputValueUnitScalingRatio;
                    double std_deviation = getStdDeviation() / outputValueUnitScalingRatio;
                    printStream.Write("#[Mean    = {0,12:F" + histogram.numberOfSignificantValueDigits + "}, " +
                                      "StdDeviation   = {1,12:F" + histogram.numberOfSignificantValueDigits + "}]\n", mean, std_deviation);
                    printStream.Write("#[Max     = {0,12:F" + histogram.numberOfSignificantValueDigits + "}, Total count    = {1,12}]\n",
                                      getMaxValue() / outputValueUnitScalingRatio, getTotalCount());
                    printStream.Write("#[Buckets = {0,12}, SubBuckets     = {1,12}]\n",
                                      histogram.bucketCount, histogram.subBucketCount);
                }
            }
            catch (ArgumentOutOfRangeException e)
            {
                // Overflow conditions on histograms can lead to ArrayIndexOutOfBoundsException on iterations:
                if (histogram.hasOverflowed())
                {
                    //printStream.format(Locale.US, "# Histogram counts indicate OVERFLOW values");
                    printStream.Write("# Histogram counts indicate OVERFLOW values");
                }
                else
                {
                    // Re-throw if reason is not a known overflow:
                    throw e;
                }
            }
        }