Search in sources :

Example 1 with Dim

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

the class Performance method assertPerformanceInRelativeBand.

/**
 * Asserts that the measurement specified by the dimension captured in the given performance meter is within a certain range
 * with respect to some reference value. If the performance meter doesn't provide the specified dimension, the call has no
 * effect.
 *
 * @param performanceMeter
 *            the performance meter
 * @param dim
 *            the Dimension to check
 * @param lowerPercentage
 *            a negative number indicating the percentage the measured value is allowed to be smaller than some reference value
 * @param upperPercentage
 *            a positive number indicating the percentage the measured value is allowed to be greater than some reference value
 * @throws RuntimeException
 *             if the properties do not hold
 */
public void assertPerformanceInRelativeBand(PerformanceMeter performanceMeter, Dimension dim, int lowerPercentage, int upperPercentage) {
    Evaluator e = new Evaluator();
    e.setAssertCheckers(new AssertChecker[] { new RelativeBandChecker((Dim) dim, 1.0 + (lowerPercentage / 100.0), 1.0 + (upperPercentage / 100.0)) });
    e.evaluate(performanceMeter);
}
Also used : RelativeBandChecker(org.eclipse.test.internal.performance.eval.RelativeBandChecker) Dim(org.eclipse.test.internal.performance.data.Dim) Evaluator(org.eclipse.test.internal.performance.eval.Evaluator) IEvaluator(org.eclipse.test.internal.performance.eval.IEvaluator)

Example 2 with Dim

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

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

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

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

the class AbsoluteBandChecker method test.

@Override
public boolean test(StatisticsSession reference, StatisticsSession measured, StringBuffer message) {
    Dim dimension = getDimension();
    if (!measured.contains(dimension)) {
        // $NON-NLS-1$
        PerformanceTestPlugin.logWarning("collected data provides no dimension '" + dimension.getName() + '\'');
        return true;
    }
    if (!reference.contains(dimension)) {
        // $NON-NLS-1$
        PerformanceTestPlugin.logWarning("reference data provides no dimension '" + dimension.getName() + '\'');
        return true;
    }
    double actual = measured.getAverage(dimension);
    double test = reference.getAverage(dimension);
    if (actual > fUpperBand + test || actual < test - fLowerBand) {
        message.append('\n' + dimension.getName() + ": " + dimension.getDisplayValue(actual) + " is not within [-" + dimension.getDisplayValue(new Scalar(null, fLowerBand)) + ", +" + dimension.getDisplayValue(new Scalar(null, fUpperBand)) + "] of " + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        dimension.getDisplayValue(test));
        return false;
    }
    return true;
}
Also used : Dim(org.eclipse.test.internal.performance.data.Dim) Scalar(org.eclipse.test.internal.performance.data.Scalar)

Aggregations

Dim (org.eclipse.test.internal.performance.data.Dim)13 DataPoint (org.eclipse.test.internal.performance.data.DataPoint)9 Scalar (org.eclipse.test.internal.performance.data.Scalar)5 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)3 StatisticsSession (org.eclipse.test.internal.performance.eval.StatisticsSession)3 SQLException (java.sql.SQLException)2 HashMap (java.util.HashMap)2 Variations (org.eclipse.test.internal.performance.db.Variations)2 Evaluator (org.eclipse.test.internal.performance.eval.Evaluator)2 IEvaluator (org.eclipse.test.internal.performance.eval.IEvaluator)2 ResultSet (java.sql.ResultSet)1 Timestamp (java.sql.Timestamp)1 MessageFormat (java.text.MessageFormat)1 CoreException (org.eclipse.core.runtime.CoreException)1 InternalPerformanceMeter (org.eclipse.test.internal.performance.InternalPerformanceMeter)1 Sample (org.eclipse.test.internal.performance.data.Sample)1 SummaryEntry (org.eclipse.test.internal.performance.db.SummaryEntry)1 AbsoluteBandChecker (org.eclipse.test.internal.performance.eval.AbsoluteBandChecker)1 RelativeBandChecker (org.eclipse.test.internal.performance.eval.RelativeBandChecker)1