Search in sources :

Example 1 with Scenario

use of org.eclipse.test.internal.performance.db.Scenario in project eclipse.platform.releng by eclipse.

the class DBTests method testAssertPerformance.

public void testAssertPerformance() throws SQLException {
    Performance perf = Performance.getDefault();
    // set the variation for the reference data
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    System.setProperty("eclipse.perf.config", CONFIG + "=test;" + BUILD + "=ref");
    // store a reference value
    TestPerformanceMeter pm1 = new TestPerformanceMeter(SCENARIO_NAME_0);
    pm1.addPair(InternalDimensions.CPU_TIME, 100, 1000);
    pm1.addPair(InternalDimensions.WORKING_SET, 1000, 2000);
    pm1.start();
    pm1.stop();
    pm1.commit();
    pm1.dispose();
    // $NON-NLS-1$
    String build = "001";
    // set the variation for the this run
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    System.setProperty("eclipse.perf.config", CONFIG + "=test;" + BUILD + "=" + build);
    // assert that this run's values are compared against reference data
    // $NON-NLS-1$ //$NON-NLS-2$
    System.setProperty("eclipse.perf.assertAgainst", BUILD + "=ref");
    // store a reference value
    TestPerformanceMeter pm2 = new TestPerformanceMeter(SCENARIO_NAME_0);
    pm2.addPair(InternalDimensions.CPU_TIME, 100, 1100);
    pm2.addPair(InternalDimensions.WORKING_SET, 1000, 2000);
    pm2.start();
    pm2.stop();
    pm2.commit();
    boolean failed = false;
    try {
        perf.assertPerformanceInRelativeBand(pm2, InternalDimensions.CPU_TIME, -5, +5);
    } catch (AssertionFailedError e) {
        failed = true;
    }
    pm2.dispose();
    if (!failed) {
        // check in DB
        Variations v = new Variations();
        // $NON-NLS-1$
        v.put(CONFIG, "%");
        v.put(BUILD, build);
        Scenario[] scenarios = DB.queryScenarios(v, SCENARIO_NAME_0, CONFIG, null);
        if (scenarios != null && scenarios.length > 0) {
            Scenario s = scenarios[0];
            String[] failureMessages = s.getFailureMessages();
            if (failureMessages.length == 1) {
                String mesg = failureMessages[0];
                if (mesg != null && // $NON-NLS-1$
                mesg.equals("Performance criteria not met when compared to '{b=ref, c=test}':\nCPU Time: 1 s is not within [95%, 105%] of 900 ms"))
                    failed = true;
            }
        }
    }
    assertTrue(failed);
}
Also used : Variations(org.eclipse.test.internal.performance.db.Variations) Performance(org.eclipse.test.performance.Performance) AssertionFailedError(junit.framework.AssertionFailedError) Scenario(org.eclipse.test.internal.performance.db.Scenario)

Aggregations

AssertionFailedError (junit.framework.AssertionFailedError)1 Scenario (org.eclipse.test.internal.performance.db.Scenario)1 Variations (org.eclipse.test.internal.performance.db.Variations)1 Performance (org.eclipse.test.performance.Performance)1