use of org.eclipse.linuxtools.internal.perf.StatComparisonData in project linuxtools by eclipse.
the class StatComparisonView method setInput.
@Override
public void setInput(Object input) {
if (input instanceof ICompareInput) {
fInput = (ICompareInput) input;
if (fInput.getAncestor() != null || (fInput.getKind() & Differencer.DIRECTION_MASK) != 0) {
setStyledText(Messages.CompUnsupported);
} else {
// get corresponding files
IPath oldDatum;
IPath newDatum;
if (fInput.getLeft() instanceof ResourceNode) {
ResourceNode left = (ResourceNode) fInput.getLeft();
oldDatum = left.getResource().getLocation();
} else {
IEncodedStreamContentAccessor lStream = (IEncodedStreamContentAccessor) fInput.getLeft();
oldDatum = generateTempFile(lStream);
}
if (fInput.getRight() instanceof ResourceNode) {
ResourceNode right = (ResourceNode) fInput.getRight();
newDatum = right.getResource().getLocation();
} else {
IEncodedStreamContentAccessor rStream = (IEncodedStreamContentAccessor) fInput.getRight();
newDatum = generateTempFile(rStream);
}
String title = MessageFormat.format(Messages.ContentDescription_0, oldDatum.toFile().getName(), newDatum.toFile().getName());
// create comparison data and run comparison.
StatComparisonData diffData;
if (reverse) {
diffData = new StatComparisonData(title, newDatum, oldDatum);
} else {
diffData = new StatComparisonData(title, oldDatum, newDatum);
}
diffData.runComparison();
updateData(diffData);
}
}
fComposite.layout();
}
use of org.eclipse.linuxtools.internal.perf.StatComparisonData in project linuxtools by eclipse.
the class StatsComparisonTest method testStatComparisonResult.
@Test
public void testStatComparisonResult() throws IOException {
IPath oldStatData = Path.fromOSString(STAT_RES + "perf_old.stat");
IPath newStatData = Path.fromOSString(STAT_RES + "perf_new.stat");
IPath diffStatData = Path.fromOSString(STAT_RES + "perf_diff.stat");
try (BufferedReader diffDataReader = new BufferedReader(new FileReader(diffStatData.toFile()))) {
StatComparisonData diffData = new StatComparisonData("title", oldStatData, newStatData);
diffData.runComparison();
String actualResult = diffData.getPerfData();
String[] actualResultLines = actualResult.split("\n");
String curLine;
for (int i = 0; i < actualResultLines.length; i++) {
curLine = diffDataReader.readLine();
/**
* Elapsed seconds are usually very close to zero, and thus
* prone to some small formatting differences across systems.
* Total time entry items are checked more thoroughly to avoid
* test failures.
*/
if (curLine.contains(PMStatEntry.TIME)) {
String expectedEntry = curLine.trim();
String actualEntry = actualResultLines[i].trim();
String expectedSamples = expectedEntry.substring(0, expectedEntry.indexOf(" "));
String expectedRest = expectedEntry.substring(expectedEntry.indexOf(" ") + 1);
String actualSamples = actualEntry.substring(0, actualEntry.indexOf(" "));
String actualRest = actualEntry.substring(actualEntry.indexOf(" ") + 1);
assertEquals(StatComparisonData.toFloat(actualSamples), StatComparisonData.toFloat(expectedSamples), 0);
assertEquals(actualRest, expectedRest);
} else {
assertEquals(actualResultLines[i], curLine);
}
}
}
}
use of org.eclipse.linuxtools.internal.perf.StatComparisonData in project linuxtools by eclipse.
the class StatsComparisonTest method testStatDataComparison.
@Test
public void testStatDataComparison() {
IPath oldStatData = Path.fromOSString(STAT_RES + "perf_old.stat");
IPath newStatData = Path.fromOSString(STAT_RES + "perf_new.stat");
StatComparisonData diffData = new StatComparisonData("title", oldStatData, newStatData);
// expected comparison list
ArrayList<PMStatEntry> expectedDiff = new ArrayList<>();
expectedDiff.add(new PMStatEntry((float) -4.0, "cpu-clock", (float) 0.0, null, (float) 0.54, (float) 0.0));
expectedDiff.add(new PMStatEntry((float) -2000.0, "page-faults", (float) -0.31, "M/sec", (float) 0.02, (float) 0.0));
expectedDiff.add(new PMStatEntry((float) 0.0, "context-switches", (float) -0.13, "K/sec", (float) 36.34, (float) 0.0));
expectedDiff.add(new PMStatEntry((float) -1000.0, "minor-faults", (float) -0.3, "M/sec", (float) 0.02, (float) 0.0));
expectedDiff.add(new PMStatEntry((float) 0.0, "major-faults", (float) 0.0, "K/sec", (float) 0.0, (float) 0.0));
expectedDiff.add(new PMStatEntry((float) -0.008, "seconds time elapsed", (float) 0.0, null, (float) 0.92, (float) 0.0));
ArrayList<PMStatEntry> actualDiff = diffData.getComparisonStats();
assertFalse(actualDiff.isEmpty());
for (PMStatEntry expectedEntry : expectedDiff) {
assertTrue(actualDiff.contains(expectedEntry));
}
}
use of org.eclipse.linuxtools.internal.perf.StatComparisonData in project linuxtools by eclipse.
the class StatsComparisonTest method testStatDataComparisonFieldGetters.
@Test
public void testStatDataComparisonFieldGetters() {
IPath oldStatData = Path.fromOSString(STAT_RES + "perf_old.stat");
IPath newStatData = Path.fromOSString(STAT_RES + "perf_new.stat");
String dataTitle = "title";
StatComparisonData diffData = new StatComparisonData(dataTitle, oldStatData, newStatData);
assertEquals(dataTitle, diffData.getTitle());
assertEquals("", diffData.getPerfData());
assertNotNull(diffData.getDataID());
assertEquals(oldStatData.toOSString(), diffData.getOldDataPath());
assertEquals(newStatData.toOSString(), diffData.getNewDataPath());
assertEquals(oldStatData.toOSString() + diffData.getDataID(), diffData.getOldDataID());
assertEquals(newStatData.toOSString() + diffData.getDataID(), diffData.getNewDataID());
}
Aggregations