Search in sources :

Example 1 with LamiTimeRange

use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimeRange 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));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) LamiTableEntryAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect) LamiData(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiData) LamiAnalysisStub(org.eclipse.tracecompass.analysis.lami.core.tests.shared.analysis.LamiAnalysisStub) LamiTimeRange(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimeRange) LamiBitrate(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiBitrate) LamiTimestamp(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimestamp) LamiResultTable(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiResultTable) LamiSize(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiSize) LamiTableEntry(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry) LamiSystemCall(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiSystemCall) LamiTableClass(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableClass) LamiDuration(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiDuration) Test(org.junit.Test)

Example 2 with LamiTimeRange

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

the class LamiTimeRangeEndAspect method resolveString.

@Override
@Nullable
public String resolveString(LamiTableEntry entry) {
    LamiData data = entry.getValue(getColIndex());
    if (data instanceof LamiTimeRange) {
        LamiTimeRange range = (LamiTimeRange) data;
        LamiTimestamp ts = range.getEnd();
        // TODO: Consider low and high limits here.
        Number timestamp = ts.getValue();
        if (timestamp != null) {
            return TmfTimestampFormat.getDefaulTimeFormat().format(timestamp.longValue());
        }
    }
    return data.toString();
}
Also used : LamiData(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiData) LamiTimestamp(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimestamp) LamiTimeRange(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimeRange) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 3 with LamiTimeRange

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

the class LamiReportViewTabPage method updateSelection.

// ------------------------------------------------------------------------
// Signals
// ------------------------------------------------------------------------
// Custom chart signals
/**
 * Signal handler for a chart selection update. It will try to propagate a
 * {@link TmfSelectionRangeUpdatedSignal} if possible.
 *
 * @param signal
 *            The selection update signal
 */
@TmfSignalHandler
public void updateSelection(ChartSelectionUpdateSignal signal) {
    /* Make sure we are not sending a signal to ourself */
    if (signal.getSource() == this) {
        return;
    }
    /* Make sure the signal comes from the data provider's scope */
    if (fResultTable.hashCode() != signal.getDataProvider().hashCode()) {
        return;
    }
    /* Find which index row has been selected */
    Set<Object> entries = signal.getSelectedObject();
    /* Update the selection */
    fSelection = entries;
    /* Only propagate to all TraceCompass if there is a single selection */
    if (entries.size() == 1) {
        LamiTableEntry entry = (LamiTableEntry) Iterables.getOnlyElement(entries);
        /* Make sure the selection represent a time range */
        LamiTimeRange timeRange = entry.getCorrespondingTimeRange();
        if (timeRange == null) {
            return;
        }
        /* Get the timestamps from the time range */
        /**
         * TODO: Consider low and high limits of timestamps here.
         */
        Number tsBeginValueNumber = timeRange.getBegin().getValue();
        Number tsEndValueNumber = timeRange.getEnd().getValue();
        if (tsBeginValueNumber == null || tsEndValueNumber == null) {
            return;
        }
        /* Send Range update to other views */
        ITmfTimestamp start = TmfTimestamp.fromNanos(tsBeginValueNumber.longValue());
        ITmfTimestamp end = TmfTimestamp.fromNanos(tsEndValueNumber.longValue());
        TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, start, end));
    }
}
Also used : TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) LamiTableEntry(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) LamiTimeRange(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimeRange) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Example 4 with LamiTimeRange

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

the class LamiTimeRangeBeginAspect method resolveString.

@Override
@Nullable
public String resolveString(LamiTableEntry entry) {
    LamiData data = entry.getValue(getColIndex());
    if (data instanceof LamiTimeRange) {
        LamiTimeRange range = (LamiTimeRange) data;
        LamiTimestamp ts = range.getBegin();
        // TODO: Consider low and high limits here.
        Number timestamp = ts.getValue();
        if (timestamp != null) {
            return TmfTimestampFormat.getDefaulTimeFormat().format(timestamp.longValue());
        }
    }
    /* Could be null, unknown, etc. */
    return data.toString();
}
Also used : LamiData(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiData) LamiTimestamp(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimestamp) LamiTimeRange(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimeRange) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 5 with LamiTimeRange

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

the class LamiTimeRangeBeginAspect method resolveNumber.

@Override
@Nullable
public Number resolveNumber(@NonNull LamiTableEntry entry) {
    LamiData data = entry.getValue(getColIndex());
    if (data instanceof LamiTimeRange) {
        LamiTimeRange range = (LamiTimeRange) data;
        LamiTimestamp ts = range.getBegin();
        // TODO: Consider low and high limits here.
        return ts.getValue();
    }
    return null;
}
Also used : LamiData(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiData) LamiTimestamp(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimestamp) LamiTimeRange(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimeRange) Nullable(org.eclipse.jdt.annotation.Nullable)

Aggregations

LamiTimeRange (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimeRange)10 LamiData (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiData)7 Nullable (org.eclipse.jdt.annotation.Nullable)6 LamiTimestamp (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimestamp)6 LamiTableEntry (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry)3 ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)2 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Status (org.eclipse.core.runtime.Status)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 LamiAnalysisStub (org.eclipse.tracecompass.analysis.lami.core.tests.shared.analysis.LamiAnalysisStub)1 NonNullUtils.nullToEmptyString (org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString)1 LamiTableEntryAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect)1 LamiResultTable (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiResultTable)1 LamiTableClass (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableClass)1