Search in sources :

Example 1 with DataPoint

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

use of org.eclipse.test.internal.performance.data.DataPoint in project eclipse.platform.releng by eclipse.

the class DB method internalQueryDataPoints.

private DataPoint[] internalQueryDataPoints(final Variations variations, final String scenarioName, final Set<Dim> dimSet) {
    if (fSQL == null) {
        return null;
    }
    long start = System.currentTimeMillis();
    if (DEBUG) {
        // $NON-NLS-1$ //$NON-NLS-2$
        System.out.print("	- query data points from DB for scenario " + scenarioName + "...");
    }
    final ArrayList<DataPoint> dataPoints = new ArrayList<>();
    try (ResultSet rs = fSQL.queryDataPoints(variations, scenarioName)) {
        if (DEBUG) {
            final long time = System.currentTimeMillis();
            // $NON-NLS-1$ //$NON-NLS-2$
            System.out.println("done in " + (time - start) + "ms");
            start = time;
        }
        while (rs.next()) {
            final int datapoint_id = rs.getInt(1);
            final int step = rs.getInt(2);
            final HashMap<Dim, Scalar> map = new HashMap<>();
            try (final ResultSet rs2 = fSQL.queryScalars(datapoint_id)) {
                while (rs2.next()) {
                    final int dim_id = rs2.getInt(1);
                    final long value = rs2.getBigDecimal(2).longValue();
                    final Dim dim = Dim.getDimension(dim_id);
                    if (dim != null) {
                        if ((dimSet == null) || dimSet.contains(dim)) {
                            map.put(dim, new Scalar(dim, value));
                        }
                    }
                }
                if (map.size() > 0) {
                    dataPoints.add(new DataPoint(step, map));
                }
            }
        }
        final int n = dataPoints.size();
        if (DEBUG) {
            final long time = System.currentTimeMillis();
            // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            System.out.println("		+ " + n + " datapoints created in " + (time - start) + "ms");
        }
        return dataPoints.toArray(new DataPoint[n]);
    } catch (final SQLException e) {
        PerformanceTestPlugin.log(e);
    }
    return null;
}
Also used : DataPoint(org.eclipse.test.internal.performance.data.DataPoint) HashMap(java.util.HashMap) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) Dim(org.eclipse.test.internal.performance.data.Dim) DataPoint(org.eclipse.test.internal.performance.data.DataPoint) Scalar(org.eclipse.test.internal.performance.data.Scalar)

Example 3 with DataPoint

use of org.eclipse.test.internal.performance.data.DataPoint 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 4 with DataPoint

use of org.eclipse.test.internal.performance.data.DataPoint in project eclipse.platform.releng by eclipse.

the class Evaluator method evaluate.

@Override
public void evaluate(PerformanceMeter performanceMeter) throws RuntimeException {
    if (fCheckers == null)
        // nothing to do
        return;
    // get reference build tag
    Variations refKeys = PerformanceTestPlugin.getAssertAgainst();
    String assertKey = System.getProperty(PerformanceTestPlugin.ECLIPSE_PERF_ASSERTAGAINST);
    if (refKeys == null) {
        // $NON-NLS-1$ //$NON-NLS-2$
        PerformanceTestPlugin.logWarning("refkeys was null. " + PerformanceTestPlugin.ECLIPSE_PERF_ASSERTAGAINST + " was " + assertKey);
        // nothing to do
        return;
    }
    // else
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    PerformanceTestPlugin.logInfo("refkeys was: " + refKeys.toString() + " \n\t based on " + PerformanceTestPlugin.ECLIPSE_PERF_ASSERTAGAINST + " being set to " + assertKey);
    if (!(performanceMeter instanceof InternalPerformanceMeter))
        // we cannot handle this.
        return;
    InternalPerformanceMeter ipm = (InternalPerformanceMeter) performanceMeter;
    Sample session = ipm.getSample();
    // $NON-NLS-1$
    Assert.assertTrue("metering session is null", session != null);
    String scenarioName = session.getScenarioID();
    // determine all dimensions we need
    HashSet<Dim> allDimensions = new HashSet<>();
    for (int i = 0; i < fCheckers.length; i++) {
        AssertChecker chk = fCheckers[i];
        Dim[] dims = chk.getDimensions();
        for (int j = 0; j < dims.length; j++) allDimensions.add(dims[j]);
    }
    // get data for this session
    DataPoint[] sessionDatapoints;
    Variations config = PerformanceTestPlugin.getVariations();
    if (config != null)
        sessionDatapoints = DB.queryDataPoints(config, scenarioName, allDimensions);
    else
        sessionDatapoints = session.getDataPoints();
    if (sessionDatapoints == null || sessionDatapoints.length == 0) {
        // $NON-NLS-1$ //$NON-NLS-2$
        PerformanceTestPlugin.logWarning("no session data named '" + config + "' found");
        return;
    }
    // get reference data
    DataPoint[] datapoints = DB.queryDataPoints(refKeys, scenarioName, allDimensions);
    if (datapoints == null || datapoints.length == 0) {
        // $NON-NLS-1$ //$NON-NLS-2$
        PerformanceTestPlugin.logWarning("no reference data named '" + refKeys + "' found");
        return;
    }
    // calculate the average
    StatisticsSession referenceStats = new StatisticsSession(datapoints);
    StatisticsSession measuredStats = new StatisticsSession(sessionDatapoints);
    // $NON-NLS-1$ //$NON-NLS-2$
    StringBuffer failMesg = new StringBuffer("Performance criteria not met when compared to '" + refKeys + "':");
    boolean pass = true;
    for (int i = 0; i < fCheckers.length; i++) {
        AssertChecker chk = fCheckers[i];
        pass &= chk.test(referenceStats, measuredStats, failMesg);
    }
    if (!pass) {
        if (config != null)
            DB.markAsFailed(config, session, failMesg.toString());
    // else
    // Assert.assertTrue(failMesg.toString(), false);
    }
}
Also used : Sample(org.eclipse.test.internal.performance.data.Sample) Variations(org.eclipse.test.internal.performance.db.Variations) Dim(org.eclipse.test.internal.performance.data.Dim) DataPoint(org.eclipse.test.internal.performance.data.DataPoint) DataPoint(org.eclipse.test.internal.performance.data.DataPoint) InternalPerformanceMeter(org.eclipse.test.internal.performance.InternalPerformanceMeter) HashSet(java.util.HashSet)

Example 5 with DataPoint

use of org.eclipse.test.internal.performance.data.DataPoint in project eclipse.platform.releng by eclipse.

the class StatisticsSession method computeStatsFromAggregates.

private Statistics computeStatsFromAggregates(Dim dimension) {
    Statistics stats = new Statistics();
    long aggregateCount = 0;
    double averageSum = 0;
    long countSum = 0;
    double stdevSum = 0;
    // Set acquiredAggregates= new HashSet();
    for (int i = 0; i < fDataPoints.length; i++) {
        DataPoint point = fDataPoints[i];
        Scalar scalar = point.getScalar(dimension);
        if (scalar == null)
            continue;
        Integer aggregate = Integer.valueOf(point.getStep());
        // allow for multiple measurements that were each stored with their own
        // aggregate values
        // Assert.assertTrue(acquiredAggregates.add(aggregate));
        long magnitude = scalar.getMagnitude();
        switch(aggregate.intValue()) {
            case InternalPerformanceMeter.AVERAGE:
                averageSum += magnitude;
                aggregateCount++;
                break;
            case InternalPerformanceMeter.STDEV:
                // see DB.internalStore
                stdevSum += Double.longBitsToDouble(magnitude);
                break;
            case InternalPerformanceMeter.SIZE:
                countSum += magnitude;
                break;
            default:
                // $NON-NLS-1$
                Assert.fail("only average, stdev and size are supported in aggregate mode");
                break;
        }
    }
    stats.average = averageSum / aggregateCount;
    // XXX this does not work! have to treat multiple runs like normal measurement
    stats.stddev = stdevSum / aggregateCount;
    // data
    stats.count = countSum;
    stats.sum = Math.round(stats.count * stats.average);
    return stats;
}
Also used : DataPoint(org.eclipse.test.internal.performance.data.DataPoint) DataPoint(org.eclipse.test.internal.performance.data.DataPoint) Scalar(org.eclipse.test.internal.performance.data.Scalar)

Aggregations

DataPoint (org.eclipse.test.internal.performance.data.DataPoint)14 Dim (org.eclipse.test.internal.performance.data.Dim)8 Scalar (org.eclipse.test.internal.performance.data.Scalar)6 HashMap (java.util.HashMap)5 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 Sample (org.eclipse.test.internal.performance.data.Sample)3 StatisticsSession (org.eclipse.test.internal.performance.eval.StatisticsSession)3 SQLException (java.sql.SQLException)2 Variations (org.eclipse.test.internal.performance.db.Variations)2 ResultSet (java.sql.ResultSet)1 Timestamp (java.sql.Timestamp)1 MessageFormat (java.text.MessageFormat)1 Map (java.util.Map)1 CoreException (org.eclipse.core.runtime.CoreException)1 InternalPerformanceMeter (org.eclipse.test.internal.performance.InternalPerformanceMeter)1 SummaryEntry (org.eclipse.test.internal.performance.db.SummaryEntry)1 Percentile (org.eclipse.test.internal.performance.eval.StatisticsUtil.Percentile)1 Dimension (org.eclipse.test.performance.Dimension)1 Performance (org.eclipse.test.performance.Performance)1