Search in sources :

Example 1 with Percentile

use of org.eclipse.test.internal.performance.eval.StatisticsUtil.Percentile in project eclipse.platform.releng by eclipse.

the class InternalPerformanceMeter method printSample.

private void printSample(PrintStream ps, Sample sample) {
    // $NON-NLS-1$ //$NON-NLS-2$
    ps.print("Scenario '" + getScenarioName() + "' ");
    DataPoint[] dataPoints = sample.getDataPoints();
    if (dataPoints.length > 0) {
        StatisticsSession s = new StatisticsSession(dataPoints);
        Dim[] dimensions = dataPoints[0].getDimensions();
        Arrays.sort(dimensions, new DimensionComparator());
        if (dimensions.length > 0) {
            List<Dim> badDimensions = new ArrayList<>();
            long n = s.getCount(dimensions[0]);
            // $NON-NLS-1$
            MessageFormat format = new MessageFormat("({0,number,percent} in [{1}, {2}])");
            // $NON-NLS-1$
            String spaces = "                                                                                                       ";
            // $NON-NLS-1$ //$NON-NLS-2$
            ps.println("(average over " + n + " samples):");
            for (Dim dimension : dimensions) {
                double mean = s.getAverage(dimension);
                // $NON-NLS-1$ //$NON-NLS-2$
                String nameString = "  " + dimension.getName() + ":";
                String meanString = dimension.getDisplayValue(mean);
                int align = firstNonDigit(meanString);
                int endIndex = 30 - align - nameString.length();
                if (endIndex > 0)
                    meanString = spaces.substring(0, endIndex) + meanString;
                align = nameString.length() + meanString.length();
                Percentile percentile = StatisticsUtil.T95;
                double[] confidenceInterval = s.getConfidenceInterval(dimension, percentile);
                StringBuffer printBuffer;
                if (n <= 2) {
                    // $NON-NLS-1$
                    printBuffer = new StringBuffer(" (no confidence)");
                } else {
                    printBuffer = new StringBuffer();
                    int ns = align;
                    while (ns++ < 40) printBuffer.append(' ');
                    printBuffer.append(format.format(new Object[] { Double.valueOf(percentile.inside()), dimension.getDisplayValue(confidenceInterval[0]), dimension.getDisplayValue(confidenceInterval[1]) }));
                }
                align += printBuffer.length();
                try {
                    while (align++ < 70) printBuffer.append(' ');
                    printBuffer.append(checkSampleSize(s, sample, dimension));
                } catch (CoreException x) {
                    badDimensions.add(dimension);
                    continue;
                }
                ps.print(nameString);
                ps.print(meanString);
                ps.println(printBuffer);
            }
            if (!badDimensions.isEmpty()) {
                // $NON-NLS-1$
                ps.print("  Dimensions with unusable statistical properties: ");
                for (Iterator<Dim> iter = badDimensions.iterator(); iter.hasNext(); ) {
                    Dim dimension = iter.next();
                    ps.print(dimension.getName());
                    if (iter.hasNext())
                        // $NON-NLS-1$
                        ps.print(", ");
                }
                ps.println();
            }
        }
    }
    ps.println();
}
Also used : Percentile(org.eclipse.test.internal.performance.eval.StatisticsUtil.Percentile) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) Dim(org.eclipse.test.internal.performance.data.Dim) DataPoint(org.eclipse.test.internal.performance.data.DataPoint) StatisticsSession(org.eclipse.test.internal.performance.eval.StatisticsSession) CoreException(org.eclipse.core.runtime.CoreException) DataPoint(org.eclipse.test.internal.performance.data.DataPoint)

Aggregations

MessageFormat (java.text.MessageFormat)1 ArrayList (java.util.ArrayList)1 CoreException (org.eclipse.core.runtime.CoreException)1 DataPoint (org.eclipse.test.internal.performance.data.DataPoint)1 Dim (org.eclipse.test.internal.performance.data.Dim)1 StatisticsSession (org.eclipse.test.internal.performance.eval.StatisticsSession)1 Percentile (org.eclipse.test.internal.performance.eval.StatisticsUtil.Percentile)1