Search in sources :

Example 1 with LamiLongNumber

use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiLongNumber in project tracecompass by tracecompass.

the class LamiChartViewerTest method testScatterMultipleRow.

/**
 * Test a few scatter charts with the multiple row dataset.
 *
 * @throws SecurityException
 *             If a security manager is present and any the wrong class is
 *             loaded or the class loader is not the same as its ancestor's
 *             loader.
 *
 * @throws IllegalArgumentException
 *             the object is not the correct class type
 */
@Test
public void testScatterMultipleRow() throws SecurityException, IllegalArgumentException {
    SWTBotView viewBot = executeAnalysis(LamiAnalyses.MULTIPLE_ROW);
    // Get the expected maximum and minimum values of each axis
    LamiResultTable resultTable = LamiAnalyses.MULTIPLE_ROW.getAnalysis().getResultTable(0);
    Long minX = Long.MAX_VALUE;
    Long maxX = Long.MIN_VALUE;
    Long minY = Long.MAX_VALUE;
    Long maxY = Long.MIN_VALUE;
    for (LamiTableEntry entry : resultTable.getEntries()) {
        Long wakeupTs = ((LamiLongNumber) entry.getValue(0)).getValue();
        Long switchTs = ((LamiLongNumber) entry.getValue(1)).getValue();
        Long latency = ((LamiLongNumber) entry.getValue(2)).getValue();
        if (wakeupTs != null) {
            minX = Math.min(minX, wakeupTs);
            maxX = Math.max(maxX, wakeupTs);
        }
        if (switchTs != null) {
            minX = Math.min(minX, switchTs);
            maxX = Math.max(maxX, switchTs);
        }
        if (latency != null) {
            minY = Math.min(minY, latency);
            maxY = Math.max(maxY, latency);
        }
    }
    // Create a new chart
    SWTBotRootMenu viewMenu = viewBot.viewMenu();
    SWTBotMenu menu = viewMenu.menu("New custom chart");
    menu.click();
    // Create a scatter chart of Wakeup timestamp vs scheduling latency
    // and Switch timestamp vs scheduling latency
    SWTBotCustomChartUtils.selectChartType(fBot, ChartType.SCATTER_CHART);
    SWTBotCustomChartUtils.addSeries(fBot, "Wakeup timestamp", Collections.singleton("Scheduling latency (ns)"));
    SWTBotCustomChartUtils.addSeries(fBot, "Switch timestamp", Collections.singleton("Scheduling latency (ns)"));
    SWTBotCustomChartUtils.confirmDialog(fBot);
    WaitUtils.waitForJobs();
    // Wait for the viewer and verify its parameters
    @Nullable Chart customChart = viewBot.bot().widget(WidgetOfType.widgetOfType(Chart.class), 0);
    Event mouseMove = new Event();
    mouseMove.type = SWT.MouseEnter;
    customChart.getDisplay().post(mouseMove);
    assertNotNull(customChart);
    fBot.waitUntil(ConditionHelpers.numberOfSeries(customChart, 2));
    SWTBotChart chartBot = new SWTBotChart(customChart);
    assertVisible(chartBot);
    // Verify the titles
    SWTBotCustomChartUtils.assertTitles(customChart, "Scheduling log", "Value (ss.SSS)", "Scheduling latency (ns)");
    // Make sure the axis formatters have the right range
    SWTBotCustomChartUtils.assertAxisRange(customChart, AxisType.X, minX, maxX);
    SWTBotCustomChartUtils.assertAxisRange(customChart, AxisType.Y, minY, maxY);
    SWTBotCustomChartUtils.assertAxisLogscale(customChart, AxisType.Y, false);
    // Verify the series titles
    SWTBotCustomChartUtils.assertSeriesTitle(customChart, ImmutableList.of("Scheduling latency by Wakeup timestamp", "Scheduling latency by Switch timestamp"));
    closeCharts();
    // Create the same chart, but with log scale enabled in Y. Make sure
    // the results are the same
    menu.click();
    SWTBotCustomChartUtils.selectChartType(fBot, ChartType.SCATTER_CHART);
    SWTBotCustomChartUtils.addSeries(fBot, "Wakeup timestamp", Collections.singleton("Scheduling latency (ns)"));
    SWTBotCustomChartUtils.addSeries(fBot, "Switch timestamp", Collections.singleton("Scheduling latency (ns)"));
    SWTBotCustomChartUtils.setLogScale(fBot, AxisType.Y);
    SWTBotCustomChartUtils.confirmDialog(fBot);
    WaitUtils.waitForJobs();
    // Wait for the viewer and verify its parameters
    customChart = viewBot.bot().widget(WidgetOfType.widgetOfType(Chart.class), 0);
    assertNotNull(customChart);
    customChart.getDisplay().post(mouseMove);
    fBot.waitUntil(ConditionHelpers.numberOfSeries(customChart, 2));
    chartBot = new SWTBotChart(customChart);
    assertVisible(chartBot);
    // Verify the titles
    SWTBotCustomChartUtils.assertTitles(customChart, "Scheduling log", "Value (ss.SSS)", "Scheduling latency (ns)");
    // Make sure the axis formatter have the right range
    SWTBotCustomChartUtils.assertAxisRange(customChart, AxisType.X, minX, maxX);
    // Logscale charts are clamped to 0
    SWTBotCustomChartUtils.assertAxisRange(customChart, AxisType.Y, 0, maxY);
    SWTBotCustomChartUtils.assertAxisLogscale(customChart, AxisType.Y, true);
    // Verify the series titles
    SWTBotCustomChartUtils.assertSeriesTitle(customChart, ImmutableList.of("Scheduling latency by Wakeup timestamp", "Scheduling latency by Switch timestamp"));
    closeCharts();
}
Also used : LamiResultTable(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiResultTable) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu) LamiTableEntry(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry) SWTBotRootMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotRootMenu) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) Event(org.eclipse.swt.widgets.Event) LamiLongNumber(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiLongNumber) Nullable(org.eclipse.jdt.annotation.Nullable) Chart(org.eclipse.swtchart.Chart) Test(org.junit.Test)

Aggregations

Nullable (org.eclipse.jdt.annotation.Nullable)1 Event (org.eclipse.swt.widgets.Event)1 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)1 SWTBotMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)1 SWTBotRootMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotRootMenu)1 Chart (org.eclipse.swtchart.Chart)1 LamiResultTable (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiResultTable)1 LamiTableEntry (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry)1 LamiLongNumber (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiLongNumber)1 Test (org.junit.Test)1