use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiData 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.types.LamiData 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();
}
use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiData in project tracecompass by tracecompass.
the class LamiAspectTest method createLamiData.
@NonNull
private static LamiTableEntry createLamiData(int i) throws JSONException {
List<@NonNull LamiData> data = new ArrayList<>();
Object nullObject = JSONObject.NULL;
assertNotNull(nullObject);
data.add(LamiData.createFromObject(nullObject));
data.add(LamiData.createFromObject(i % 2 == 1 ? "hot" : "cold"));
Boolean boolValue = Boolean.valueOf(i % 2 == 1);
assertNotNull(boolValue);
data.add(LamiData.createFromObject(boolValue));
Integer intValue = Integer.valueOf(i);
assertNotNull(intValue);
data.add(LamiData.createFromObject(intValue));
Double doubleValue = Double.valueOf(i);
assertNotNull(doubleValue);
data.add(LamiData.createFromObject(doubleValue));
/* note, this is x10 + 2, this is deliberate. */
String timerangeString = "{\n" + " \"begin\": " + i + ",\n" + " \"class\": \"time-range\",\n" + " \"end\": " + i + 2 + "\n" + "}";
data.add(LamiData.createFromObject(new JSONObject(timerangeString)));
return new LamiTableEntry(data);
}
use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiData in project tracecompass by tracecompass.
the class LamiMixedAspect method resolveString.
@Override
@Nullable
public String resolveString(LamiTableEntry entry) {
LamiData data = entry.getValue(getColIndex());
Class<? extends LamiData> cls = data.getClass();
DataType dataType = DataType.fromClass(cls);
if (dataType == null) {
return data.toString();
}
String str = data.toString();
if (dataType.getUnits() != null) {
// $NON-NLS-1$
str += " " + dataType.getUnits();
}
return str;
}
use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiData 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();
}
Aggregations