use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry in project tracecompass by tracecompass.
the class LamiAspectTest method lamiMixedAspectTest.
/**
* Test the mixed aspect
*
* @throws JSONException
* won't happen
*/
@Test
public void lamiMixedAspectTest() throws JSONException {
LamiTableEntryAspect aspect = new LamiMixedAspect(ASPECT_NAME, 0);
LamiTableEntry entry1 = createLamiData(1);
LamiTableEntry entry2 = createLamiData(2);
assertEquals(ASPECT_NAME, aspect.getLabel());
assertEquals(ASPECT_NAME, aspect.getName());
assertEquals(0, aspect.getComparator().compare(entry1, entry2));
assertNull(aspect.resolveString(entry1));
assertNull(aspect.resolveNumber(entry1));
}
use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry 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();
}
use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry in project tracecompass by tracecompass.
the class LamiTableContentProvider method updateElement.
@Override
public void updateElement(int index) {
final TableViewer tableViewer = fTableViewer;
final List<LamiTableEntry> entries = fCurrentEntries;
if ((tableViewer != null) && (entries.size() > index) && !fOngoingUpdate) {
fOngoingUpdate = true;
tableViewer.replace(entries.get(index), index);
fOngoingUpdate = false;
}
}
use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry in project tracecompass by tracecompass.
the class LamiTableContentProvider method setSortOrder.
@Override
public void setSortOrder(@Nullable Comparator<?> comparator) {
if (comparator == null) {
return;
}
final TableViewer tableViewer = fTableViewer;
if (tableViewer == null) {
return;
}
@SuppressWarnings("unchecked") Comparator<LamiTableEntry> entryComparator = (Comparator<LamiTableEntry>) comparator;
fComparator = entryComparator;
Collections.sort(fCurrentEntries, fComparator);
tableViewer.refresh();
}
use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry in project tracecompass by tracecompass.
the class LamiTableViewer method fillData.
/**
* Update the data in the table viewer
*
* @param dataInput
* New data input
*/
private void fillData() {
final TableViewer tableViewer = getTableViewer();
Display.getDefault().asyncExec(() -> {
if (tableViewer.getTable().isDisposed()) {
return;
}
// Go to the top of the table
tableViewer.getTable().setTopIndex(0);
// Reset selected row
tableViewer.setSelection(StructuredSelection.EMPTY);
/* Fill the table data */
tableViewer.setInput(fPage.getResultTable().getEntries());
LamiTableContentProvider latencyContentProvider = (LamiTableContentProvider) getTableViewer().getContentProvider();
tableViewer.setItemCount(latencyContentProvider.getNbEntries());
/* Set the column's alignment and pack them */
TableColumn[] cols = tableViewer.getTable().getColumns();
for (int i = 0; i < cols.length; i++) {
LamiTableEntryAspect colAspect = fPage.getResultTable().getTableClass().getAspects().get(i);
int alignment = (colAspect.isContinuous() ? SWT.RIGHT : SWT.LEFT);
cols[i].setAlignment(alignment);
}
/*
* On creation check if there is selections if so update the table
* selections here. Selections needs the ContentProvider for valid
* index lookup and since the content provider is set in an
* asynchronous task we cannot use the normal signal handler since
* we have no guarantee of time of execution of the fill data.
*/
if (!fSelection.isEmpty()) {
LamiTableContentProvider provider = (LamiTableContentProvider) getTableViewer().getContentProvider();
/* Find the indexes in the UI table of the selected objects */
int[] selectionsIndexes = fSelection.stream().map(obj -> (LamiTableEntry) obj).mapToInt(entry -> provider.getIndexOf(checkNotNull(entry))).toArray();
/* Update the selection in the UI table */
Display.getDefault().asyncExec(() -> {
getTableViewer().getTable().setSelection(selectionsIndexes);
getTableViewer().getTable().redraw();
});
}
});
Display.getDefault().asyncExec(() -> {
if (tableViewer.getTable().isDisposed()) {
return;
}
TableColumn[] cols = tableViewer.getTable().getColumns();
for (int i = 0; i < cols.length; i++) {
cols[i].pack();
}
});
}
Aggregations