use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiResultTable in project tracecompass by tracecompass.
the class LamiJsonParserTest method testResults.
/**
* Test the results parsing.
*
* @throws CoreException when execute() fails.
*/
@Test
public void testResults() throws CoreException {
LamiAnalysisStub analysis = new LamiAnalysisStub("Stub analysis", "test-metadata.json", "test-results.json");
LamiTmfTraceStub trace = fTrace;
assertNotNull(trace);
List<LamiResultTable> resultTables = analysis.execute(trace, null, "", new NullProgressMonitor());
assertFalse(resultTables.isEmpty());
assertEquals(4, resultTables.size());
LamiResultTable perProcessTable = resultTables.get(0);
LamiResultTable perSyscallTable = resultTables.get(1);
LamiResultTable perInterruptTable = resultTables.get(2);
LamiResultTable perInterruptOverrideTable = resultTables.get(3);
assertEquals("Per-process stuff", perProcessTable.getTableClass().getTableTitle());
assertEquals("per-proc", perProcessTable.getTableClass().getTableClassName());
assertEquals("Per-syscall stuff", perSyscallTable.getTableClass().getTableTitle());
assertEquals("per-syscall", perSyscallTable.getTableClass().getTableClassName());
assertEquals("Per-interrupt stuff", perInterruptTable.getTableClass().getTableTitle());
assertEquals("per-irq", perInterruptTable.getTableClass().getTableClassName());
assertEquals("Per-interrupt stuff [with overridden title]", perInterruptOverrideTable.getTableClass().getTableTitle());
assertEquals("Extended per-irq", perInterruptOverrideTable.getTableClass().getTableClassName());
LamiTimeRange expectedTimeRange = new LamiTimeRange(new LamiTimestamp(1000), new LamiTimestamp(2000));
assertEquals(expectedTimeRange, perProcessTable.getTimeRange());
List<LamiTableEntry> syscallEntries = perSyscallTable.getEntries();
assertFalse(syscallEntries.isEmpty());
assertEquals(5, syscallEntries.size());
LamiTableEntry readEntry = syscallEntries.get(0);
LamiTimeRange readEntryTimeRange = readEntry.getCorrespondingTimeRange();
expectedTimeRange = new LamiTimeRange(new LamiTimestamp(98233), new LamiTimestamp(1293828));
assertNotNull(readEntryTimeRange);
assertEquals(expectedTimeRange, readEntryTimeRange);
/* Test raw values */
LamiData value0 = readEntry.getValue(0);
assertTrue(value0 instanceof LamiSystemCall);
assertEquals("read", ((LamiSystemCall) value0).getValue());
LamiData value1 = readEntry.getValue(1);
assertTrue(value1 instanceof LamiDuration);
assertEquals(new LamiDuration(2398123), value1);
LamiData value2 = readEntry.getValue(2);
assertTrue(value2 instanceof LamiSize);
assertEquals(new LamiSize(8123982), value2);
LamiData value3 = readEntry.getValue(3);
assertTrue(value3 instanceof LamiBitrate);
assertEquals(new LamiBitrate(223232), value3);
LamiData value4 = readEntry.getValue(4);
expectedTimeRange = new LamiTimeRange(new LamiTimestamp(98233), new LamiTimestamp(1293828));
assertTrue(value4 instanceof LamiTimeRange);
assertEquals(expectedTimeRange, value4);
/* Test with aspects */
Map<String, LamiTableClass> tableModels = analysis.getTableClasses();
assertNotNull(tableModels);
LamiTableClass perSyscallClass = tableModels.get("per-syscall");
assertNotNull(perSyscallClass);
List<LamiTableEntryAspect> aspects = perSyscallClass.getAspects();
assertEquals("read()", aspects.get(0).resolveString(readEntry));
assertEquals(2398123.0, checkNotNull(aspects.get(1).resolveNumber(readEntry)).doubleValue(), DELTA);
assertEquals(8123982.0, checkNotNull(aspects.get(2).resolveNumber(readEntry)).doubleValue(), DELTA);
assertEquals(223232.0, checkNotNull(aspects.get(3).resolveNumber(readEntry)).doubleValue(), DELTA);
assertEquals(98233.0, checkNotNull(aspects.get(4).resolveNumber(readEntry)).doubleValue(), DELTA);
assertEquals(1293828.0, checkNotNull(aspects.get(5).resolveNumber(readEntry)).doubleValue(), DELTA);
assertEquals(1195595.0, checkNotNull(aspects.get(6).resolveNumber(readEntry)).doubleValue(), DELTA);
assertNull(aspects.get(7).resolveString(readEntry));
}
use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiResultTable in project tracecompass by tracecompass.
the class LamiReportView method createPartControl.
// ------------------------------------------------------------------------
// ViewPart
// ------------------------------------------------------------------------
@Override
public void createPartControl(@Nullable Composite parent) {
LamiAnalysisReport report = fReport;
if (report == null || parent == null) {
return;
}
setPartName(report.getName());
fTabFolder = new CTabFolder(parent, SWT.NONE);
fTabFolder.setSimple(false);
for (LamiResultTable table : report.getTables()) {
String name = table.getTableClass().getTableTitle();
CTabItem tabItem = new CTabItem(fTabFolder, SWT.NULL);
tabItem.setText(name);
SashForm sf = new SashForm(fTabFolder, SWT.NONE);
fTabPages.add(new LamiReportViewTabPage(sf, table));
tabItem.setControl(sf);
}
/* Add toolbar buttons */
Action toggleTableAction = new ToggleTableAction();
toggleTableAction.setText(Messages.LamiReportView_ActivateTableAction_ButtonName);
toggleTableAction.setToolTipText(Messages.LamiReportView_ActivateTableAction_ButtonTooltip);
// $NON-NLS-1$
toggleTableAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath("icons/table.gif"));
IActionBars actionBars = getViewSite().getActionBars();
IToolBarManager toolbarMgr = actionBars.getToolBarManager();
toolbarMgr.add(toggleTableAction);
fNewChartAction.setText(Messages.LamiReportView_NewCustomChart);
fClearCustomViewsAction.setText(Messages.LamiReportView_ClearAllCustomViews);
IMenuManager menuMgr = actionBars.getMenuManager();
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener((@Nullable IMenuManager manager) -> {
if (manager != null) {
populateMenu(manager);
}
});
populateMenu(menuMgr);
/* Select the first tab initially */
CTabFolder tf = checkNotNull(fTabFolder);
if (tf.getItemCount() > 0) {
tf.setSelection(0);
}
}
use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiResultTable 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.LamiResultTable in project tracecompass by tracecompass.
the class RunAnalysisHandler method execute.
@Override
@Nullable
public Object execute(@Nullable ExecutionEvent event) throws ExecutionException {
/* Types should have been checked by the plugin.xml already */
ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
Object element = ((IStructuredSelection) selection).getFirstElement();
final TmfOnDemandAnalysisElement analysisElem = (TmfOnDemandAnalysisElement) element;
TmfCommonProjectElement traceElem = analysisElem.getParent().getParent();
ITmfTrace trace = traceElem.getTrace();
if (trace == null) {
/* That trace is not currently opened */
return null;
}
/* Retrieve and initialize the analysis module, aka read the script's metadata */
IOnDemandAnalysis ondemandAnalysis = analysisElem.getAnalysis();
if (!(ondemandAnalysis instanceof LamiAnalysis)) {
return null;
}
LamiAnalysis analysis = (LamiAnalysis) ondemandAnalysis;
/* Retrieve the current time range, will be used as parameters to the analysis */
TmfTraceManager tm = TmfTraceManager.getInstance();
TmfTimeRange timeRange = tm.getCurrentTraceContext().getSelectionRange();
if (timeRange.getStartTime().equals(timeRange.getEndTime())) {
timeRange = null;
}
/* Job below needs a final reference... */
final TmfTimeRange tr = timeRange;
/* Pop the dialog to ask for extra parameters */
String baseCommand = analysis.getFullCommandAsString(trace, tr);
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
ParameterDialog dialog = new ParameterDialog(shell, Messages.ParameterDialog_ExternalParameters, Messages.ParameterDialog_ExternalParametersDescription, baseCommand, null);
if (dialog.open() != Window.OK) {
/* User clicked Cancel, don't run */
return null;
}
String extraParams = nullToEmptyString(dialog.getValue());
/* Execute the analysis and produce the reports */
Job job = new Job(Messages.LamiAnalysis_MainTaskName) {
@Override
@Nullable
protected IStatus run(@Nullable IProgressMonitor monitor) {
IProgressMonitor mon = (monitor == null ? new NullProgressMonitor() : monitor);
try {
List<LamiResultTable> results = analysis.execute(trace, tr, extraParams, mon);
String reportName = analysis.getName() + ' ' + Messages.ParameterDialog_ReportNameSuffix;
LamiAnalysisReport report = new LamiAnalysisReport(reportName, results);
registerNewReport(analysisElem, report);
/* Automatically open the report for convenience */
Display.getDefault().syncExec(() -> {
try {
LamiReportViewFactory.createNewView(report);
} catch (PartInitException e) {
}
});
return Status.OK_STATUS;
} catch (CoreException e) {
/*
* The analysis execution did not complete normally, we will
* report it to the user.
*/
IStatus status = e.getStatus();
/* Don't display a dialog if it was simply cancelled by the user */
if (status.matches(IStatus.CANCEL)) {
return status;
}
String dialogTitle;
String dialogMessage;
if (status.matches(IStatus.ERROR)) {
dialogTitle = Messages.ErrorDialog_Error;
dialogMessage = Messages.ErrorDialog_ErrorMessage;
} else {
dialogTitle = Messages.ErrorDialog_Info;
dialogMessage = Messages.ErrorDialog_InfoMessage;
}
Display.getDefault().asyncExec(() -> {
ErrorDialog.openError(shell, dialogTitle, dialogMessage, status);
});
/*
* We showed our own error message, no need for the Job to
* show another one.
*/
return Status.OK_STATUS;
}
}
};
job.schedule();
return null;
}
Aggregations