Search in sources :

Example 1 with SummaryEntry

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

the class DBTests method testBasicDBFunctionality.

public void testBasicDBFunctionality() {
    Performance perf = Performance.getDefault();
    TestPerformanceMeter pm1 = new TestPerformanceMeter(SCENARIO_NAME_1);
    pm1.addPair(InternalDimensions.CPU_TIME, 100, 1000);
    pm1.addPair(InternalDimensions.WORKING_SET, 1000, 2000);
    pm1.start();
    pm1.stop();
    pm1.commit();
    pm1.dispose();
    TestPerformanceMeter pm2 = new TestPerformanceMeter(SCENARIO_NAME_2);
    pm2.addPair(InternalDimensions.CPU_TIME, 100, 1000);
    pm2.addPair(InternalDimensions.WORKING_SET, 1000, 2000);
    perf.tagAsGlobalSummary(pm2, SHORT_NAME_2, new Dimension[] { Dimension.CPU_TIME, Dimension.USED_JAVA_HEAP });
    pm2.start();
    pm2.stop();
    pm2.commit();
    pm2.dispose();
    TestPerformanceMeter pm3 = new TestPerformanceMeter(SCENARIO_NAME_3);
    pm3.addPair(InternalDimensions.CPU_TIME, 100, 1000);
    pm3.addPair(InternalDimensions.WORKING_SET, 1000, 2000);
    perf.tagAsGlobalSummary(pm3, SHORT_NAME_3, Dimension.CPU_TIME);
    pm3.start();
    pm3.stop();
    pm3.commit();
    pm3.dispose();
    TestPerformanceMeter pm4 = new TestPerformanceMeter(SCENARIO_NAME_4);
    pm4.addPair(InternalDimensions.CPU_TIME, 100, 1000);
    pm4.addPair(InternalDimensions.WORKING_SET, 1000, 2000);
    perf.tagAsSummary(pm4, SHORT_NAME_4, Dimension.USED_JAVA_HEAP);
    pm4.start();
    pm4.stop();
    pm4.commit();
    pm4.dispose();
    // 
    Variations v = new Variations();
    // $NON-NLS-1$
    v.put(CONFIG, "test");
    // $NON-NLS-1$
    v.put(BUILD, "b0001");
    // $NON-NLS-1$ //$NON-NLS-2$
    v.put("jvm", "sun142");
    DataPoint[] points = DB.queryDataPoints(v, SCENARIO_NAME_1, null);
    assertEquals(1, points.length);
    DataPoint dp = points[0];
    Dim[] dimensions = dp.getDimensions();
    assertEquals(2, dimensions.length);
    Scalar s1 = dp.getScalar(InternalDimensions.CPU_TIME);
    assertNotNull(s1);
    assertEquals(900, s1.getMagnitude());
    Scalar s2 = dp.getScalar(InternalDimensions.WORKING_SET);
    assertNotNull(s2);
    assertEquals(1000, s2.getMagnitude());
    // 
    Set<Dim> dims = new HashSet<>();
    dims.add(InternalDimensions.WORKING_SET);
    points = DB.queryDataPoints(v, SCENARIO_NAME_1, dims);
    assertEquals(1, points.length);
    dimensions = points[0].getDimensions();
    assertEquals(1, dimensions.length);
    Scalar s = points[0].getScalar(InternalDimensions.WORKING_SET);
    assertNotNull(s);
    assertEquals(1000, s.getMagnitude());
    // 
    List<String> buildNames = new ArrayList<>();
    Variations v2 = new Variations();
    // $NON-NLS-1$
    v2.put(CONFIG, "%");
    // $NON-NLS-1$
    v2.put(BUILD, "b%");
    // $NON-NLS-1$
    DB.queryDistinctValues(buildNames, BUILD, v2, "%");
    assertEquals(1, buildNames.size());
    // $NON-NLS-1$
    assertEquals("b0001", buildNames.get(0));
    SummaryEntry[] fps = DB.querySummaries(PerformanceTestPlugin.getVariations(), null);
    assertEquals(3, fps.length);
    assertEquals(SCENARIO_NAME_2, fps[0].scenarioName);
    assertEquals(SHORT_NAME_2, fps[0].shortName);
    assertEquals(Dimension.USED_JAVA_HEAP, fps[0].dimension);
    assertEquals(SCENARIO_NAME_2, fps[1].scenarioName);
    assertEquals(SHORT_NAME_2, fps[1].shortName);
    assertEquals(Dimension.CPU_TIME, fps[1].dimension);
    assertEquals(SCENARIO_NAME_3, fps[2].scenarioName);
    assertEquals(SHORT_NAME_3, fps[2].shortName);
    assertEquals(Dimension.CPU_TIME, fps[2].dimension);
    // $NON-NLS-1$
    SummaryEntry[] fps2 = DB.querySummaries(PerformanceTestPlugin.getVariations(), "foo.%");
    assertEquals(2, fps2.length);
    assertEquals(SCENARIO_NAME_3, fps2[0].scenarioName);
    assertEquals(SHORT_NAME_3, fps2[0].shortName);
    assertEquals(Dimension.CPU_TIME, fps2[0].dimension);
    assertEquals(SCENARIO_NAME_4, fps2[1].scenarioName);
    assertEquals(SHORT_NAME_4, fps2[1].shortName);
    assertEquals(Dimension.USED_JAVA_HEAP, fps2[1].dimension);
}
Also used : Variations(org.eclipse.test.internal.performance.db.Variations) ArrayList(java.util.ArrayList) Dim(org.eclipse.test.internal.performance.data.Dim) Scalar(org.eclipse.test.internal.performance.data.Scalar) DataPoint(org.eclipse.test.internal.performance.data.DataPoint) SummaryEntry(org.eclipse.test.internal.performance.db.SummaryEntry) Performance(org.eclipse.test.performance.Performance) HashSet(java.util.HashSet)

Aggregations

ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 DataPoint (org.eclipse.test.internal.performance.data.DataPoint)1 Dim (org.eclipse.test.internal.performance.data.Dim)1 Scalar (org.eclipse.test.internal.performance.data.Scalar)1 SummaryEntry (org.eclipse.test.internal.performance.db.SummaryEntry)1 Variations (org.eclipse.test.internal.performance.db.Variations)1 Performance (org.eclipse.test.performance.Performance)1