Search in sources :

Example 1 with StatisticsSession

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

the class DB method internalStore.

private boolean internalStore(final Variations variations, final Sample sample) {
    if ((fSQL == null) || (sample == null)) {
        return false;
    }
    final DataPoint[] dataPoints = sample.getDataPoints();
    final int n = dataPoints.length;
    if (n <= 0) {
        return false;
    }
    // System.out.println("store started..."); //$NON-NLS-1$
    try {
        // long l= System.currentTimeMillis();
        final int variation_id = fSQL.getVariations(variations);
        final int scenario_id = fSQL.getScenario(sample.getScenarioID());
        final String comment = sample.getComment();
        if (sample.isSummary()) {
            final boolean isGlobal = sample.isGlobal();
            int commentId = 0;
            final int commentKind = sample.getCommentType();
            if ((commentKind == Performance.EXPLAINS_DEGRADATION_COMMENT) && (comment != null)) {
                commentId = fSQL.getCommentId(commentKind, comment);
            }
            final Dimension[] summaryDimensions = sample.getSummaryDimensions();
            for (final Dimension dimension : summaryDimensions) {
                if (dimension instanceof Dim) {
                    fSQL.createSummaryEntry(variation_id, scenario_id, ((Dim) dimension).getId(), isGlobal, commentId);
                }
            }
            final String shortName = sample.getShortname();
            if (shortName != null) {
                fSQL.setScenarioShortName(scenario_id, shortName);
            }
        } else if (comment != null) {
            int commentId = 0;
            final int commentKind = sample.getCommentType();
            if (commentKind == Performance.EXPLAINS_DEGRADATION_COMMENT) {
                commentId = fSQL.getCommentId(commentKind, comment);
            }
            // use
            fSQL.createSummaryEntry(variation_id, scenario_id, 0, false, commentId);
        // special
        // dim
        // id
        // '0'
        // to
        // identify
        // summary
        // entry
        // created
        // to
        // only
        // handle
        // a
        // comment
        }
        final int sample_id = fSQL.createSample(variation_id, scenario_id, new Timestamp(sample.getStartTime()));
        if (AGGREGATE) {
            final StatisticsSession stats = new StatisticsSession(dataPoints);
            final Dim[] dims = dataPoints[0].getDimensions();
            int datapoint_id = fSQL.createDataPoint(sample_id, 0, InternalPerformanceMeter.AVERAGE);
            for (final Dim dim : dims) {
                fSQL.insertScalar(datapoint_id, dim.getId(), (long) stats.getAverage(dim));
            }
            datapoint_id = fSQL.createDataPoint(sample_id, 0, InternalPerformanceMeter.STDEV);
            for (final Dim dim : dims) {
                // see StatisticsSession
                final long value = Double.doubleToLongBits(stats.getStddev(dim));
                fSQL.insertScalar(datapoint_id, dim.getId(), value);
            }
            datapoint_id = fSQL.createDataPoint(sample_id, 0, InternalPerformanceMeter.SIZE);
            for (final Dim dim : dims) {
                fSQL.insertScalar(datapoint_id, dim.getId(), stats.getCount(dim));
            }
        } else {
            for (int i = 0; i < dataPoints.length; i++) {
                final DataPoint dp = dataPoints[i];
                final int datapoint_id = fSQL.createDataPoint(sample_id, i, dp.getStep());
                final Scalar[] scalars = dp.getScalars();
                for (final Scalar scalar : scalars) {
                    final int dim_id = scalar.getDimension().getId();
                    final long value = scalar.getMagnitude();
                    fSQL.insertScalar(datapoint_id, dim_id, value);
                }
            }
        }
        fConnection.commit();
        fStoredSamples++;
        fStoreCalled = true;
    // System.err.println(System.currentTimeMillis()-l);
    } catch (final SQLException e) {
        PerformanceTestPlugin.log(e);
        try {
            fConnection.rollback();
        } catch (final SQLException e1) {
            PerformanceTestPlugin.log(e1);
        }
    }
    return true;
}
Also used : SQLException(java.sql.SQLException) Dim(org.eclipse.test.internal.performance.data.Dim) Dimension(org.eclipse.test.performance.Dimension) Timestamp(java.sql.Timestamp) DataPoint(org.eclipse.test.internal.performance.data.DataPoint) Scalar(org.eclipse.test.internal.performance.data.Scalar) StatisticsSession(org.eclipse.test.internal.performance.eval.StatisticsSession) DataPoint(org.eclipse.test.internal.performance.data.DataPoint)

Example 2 with StatisticsSession

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

the class Scenario method loadSessions.

private void loadSessions() {
    if (fSessions != null)
        return;
    loadSeriesNames();
    long start;
    Variations v = (Variations) fSharedState.fVariations.clone();
    if (DEBUG)
        start = System.currentTimeMillis();
    ArrayList<StatisticsSession> sessions = new ArrayList<>();
    ArrayList<String> names2 = new ArrayList<>();
    Set<Dim> dims = new HashSet<>();
    for (String fSeriesName : fSeriesNames) {
        v.put(fSharedState.fSeriesKey, fSeriesName);
        DataPoint[] dps = DB.queryDataPoints(v, fScenarioName, fSharedState.fQueryDimensions);
        if (DEBUG)
            // $NON-NLS-1$
            System.err.println("  dps length: " + dps.length);
        if (dps.length > 0) {
            dims.addAll(dps[0].getDimensions2());
            sessions.add(new StatisticsSession(dps));
            names2.add(fSeriesName);
        }
    }
    if (DEBUG)
        // $NON-NLS-1$
        System.err.println("data: " + (System.currentTimeMillis() - start));
    fSessions = sessions.toArray(new StatisticsSession[sessions.size()]);
    fSeriesNames = names2.toArray(new String[sessions.size()]);
    fDimensions = dims.toArray(new Dim[dims.size()]);
    Arrays.sort(fDimensions, (o1, o2) -> {
        Dim d1 = o1;
        Dim d2 = o2;
        return d1.getName().compareTo(d2.getName());
    });
}
Also used : StatisticsSession(org.eclipse.test.internal.performance.eval.StatisticsSession) DataPoint(org.eclipse.test.internal.performance.data.DataPoint) ArrayList(java.util.ArrayList) Dim(org.eclipse.test.internal.performance.data.Dim) HashSet(java.util.HashSet)

Example 3 with StatisticsSession

use of org.eclipse.test.internal.performance.eval.StatisticsSession 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

DataPoint (org.eclipse.test.internal.performance.data.DataPoint)3 Dim (org.eclipse.test.internal.performance.data.Dim)3 StatisticsSession (org.eclipse.test.internal.performance.eval.StatisticsSession)3 ArrayList (java.util.ArrayList)2 SQLException (java.sql.SQLException)1 Timestamp (java.sql.Timestamp)1 MessageFormat (java.text.MessageFormat)1 HashSet (java.util.HashSet)1 CoreException (org.eclipse.core.runtime.CoreException)1 Scalar (org.eclipse.test.internal.performance.data.Scalar)1 Percentile (org.eclipse.test.internal.performance.eval.StatisticsUtil.Percentile)1 Dimension (org.eclipse.test.performance.Dimension)1