use of org.eclipse.tracecompass.internal.tmf.core.synchronization.TmfTimestampTransformLinearFast in project tracecompass by tracecompass.
the class SyncTest method testFullyIncremental.
/**
* Testing fully incremental algorithm with communication between the two
* traces
*/
@Test
public void testFullyIncremental() {
SynchronizationAlgorithm syncAlgo = SynchronizationAlgorithmFactory.getFullyIncrementalAlgorithm();
syncAlgo.init(fTraces);
assertEquals(SyncQuality.ABSENT, syncAlgo.getSynchronizationQuality(t1, t2));
addSyncMatch(syncAlgo, t2, 1, t1, 1);
assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 1 beta 0 ]]", syncAlgo.toString());
assertEquals(SyncQuality.INCOMPLETE, syncAlgo.getSynchronizationQuality(t1, t2));
addSyncMatch(syncAlgo, t1, 1, t2, 3);
assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 1 beta 0 ]]", syncAlgo.toString());
assertEquals(SyncQuality.INCOMPLETE, syncAlgo.getSynchronizationQuality(t1, t2));
addSyncMatch(syncAlgo, t2, 2, t1, 3);
assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 1 beta 0.5 ]]", syncAlgo.toString());
assertEquals(SyncQuality.APPROXIMATE, syncAlgo.getSynchronizationQuality(t1, t2));
addSyncMatch(syncAlgo, t1, 3, t2, 5);
assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 0.75 beta 1.25 ]]", syncAlgo.toString());
assertEquals(SyncQuality.ACCURATE, syncAlgo.getSynchronizationQuality(t1, t2));
addSyncMatch(syncAlgo, t1, 4, t2, 8);
assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 0.75 beta 1.25 ]]", syncAlgo.toString());
assertEquals(SyncQuality.ACCURATE, syncAlgo.getSynchronizationQuality(t1, t2));
addSyncMatch(syncAlgo, t2, 4, t1, 5);
assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 1.125 beta 0.875 ]]", syncAlgo.toString());
assertEquals(SyncQuality.ACCURATE, syncAlgo.getSynchronizationQuality(t1, t2));
addSyncMatch(syncAlgo, t2, 4, t1, 6);
assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 1.125 beta 0.875 ]]", syncAlgo.toString());
assertEquals(SyncQuality.ACCURATE, syncAlgo.getSynchronizationQuality(t1, t2));
addSyncMatch(syncAlgo, t1, 6, t2, 7);
assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 0.725 beta 1.275 ]]", syncAlgo.toString());
assertEquals(SyncQuality.ACCURATE, syncAlgo.getSynchronizationQuality(t1, t2));
ITmfTimestampTransform tt2 = syncAlgo.getTimestampTransform(t2);
ITmfTimestampTransform tt1 = syncAlgo.getTimestampTransform(t1);
assertEquals(syncAlgo.getTimestampTransform(t1.getHostId()), tt1);
assertEquals(TimestampTransformFactory.getDefaultTransform(), tt1);
assertEquals(syncAlgo.getTimestampTransform(t2.getHostId()), tt2);
assertTrue(tt2 instanceof TmfTimestampTransformLinearFast);
/*
* Make the two hulls intersect, and make sure the last good formula is
* kept after failure
*/
addSyncMatch(syncAlgo, t1, 7, t2, 4);
assertEquals(SyncQuality.ACCURATE, syncAlgo.getSynchronizationQuality(t1, t2));
assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 0.375 beta 1.625 ]]", syncAlgo.toString());
// Last good synchronization
tt2 = syncAlgo.getTimestampTransform(t2);
tt1 = syncAlgo.getTimestampTransform(t1);
assertTrue(tt2 instanceof TmfTimestampTransformLinearFast);
addSyncMatch(syncAlgo, t2, 7, t1, 3);
assertEquals(SyncQuality.FAIL, syncAlgo.getSynchronizationQuality(t1, t2));
assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 0.375 beta 1.625 ]]", syncAlgo.toString());
assertEquals(tt2, syncAlgo.getTimestampTransform(t2.getHostId()));
assertEquals(tt1, syncAlgo.getTimestampTransform(t1.getHostId()));
assertEquals(TimestampTransformFactory.getDefaultTransform(), tt1);
}
use of org.eclipse.tracecompass.internal.tmf.core.synchronization.TmfTimestampTransformLinearFast in project tracecompass by tracecompass.
the class TsTransformFastTest method testFastTransformSlopeAndOffset.
/**
* Test that fast transform produces the same result with a slope and
* offset, for small and large values
*/
@Test
public void testFastTransformSlopeAndOffset() {
double offset = 54321.0;
double slope = Math.pow(10.0, 4);
for (int ex = 0; ex <= Long.SIZE - 1; ex++) {
long start = 1 << ex;
TmfTimestampTransformLinear precise = new TmfTimestampTransformLinear(slope, offset);
TmfTimestampTransformLinearFast fast = fTransformFactory.create(slope, offset);
checkTime(precise, fast, 5, start, 1);
}
}
use of org.eclipse.tracecompass.internal.tmf.core.synchronization.TmfTimestampTransformLinearFast in project tracecompass by tracecompass.
the class TsTransformFastTest method testFastTransformPrecision.
/**
* Test the precision of the fast timestamp transform compared to the
* original transform.
*/
@Test
public void testFastTransformPrecision() {
TmfTimestampTransformLinear precise = new TmfTimestampTransformLinear(Math.PI, 0);
TmfTimestampTransformLinearFast fast = fTransformFactory.create(Math.PI, 0);
int samples = 100;
long start = (long) Math.pow(10, 18);
long end = Long.MAX_VALUE;
int step = (int) ((end - start) / (samples * Math.PI));
checkTime(precise, fast, samples, start, step);
assertEquals(samples, fast.getCacheMisses());
// check that rescale is done only when required
// assumes tsBitWidth == 30
// test forward and backward timestamps
samples = 1000;
int[] directions = new int[] { 1, -1 };
for (Integer direction : directions) {
for (int i = 0; i <= 30; i++) {
fast.resetScaleStats();
step = (1 << i) * direction;
checkTime(precise, fast, samples, start, step);
assertTrue(String.format("samples: %d scale misses: %d", samples, fast.getCacheMisses()), samples >= fast.getCacheMisses());
}
}
}
use of org.eclipse.tracecompass.internal.tmf.core.synchronization.TmfTimestampTransformLinearFast in project tracecompass by tracecompass.
the class TsTransformFastTest method testFLTEquivalence.
/**
* Test that 2 equal fast transform always give the same results for the
* same values
*/
@Test
public void testFLTEquivalence() {
TmfTimestampTransformLinearFast fast = fTransformFactory.create(Math.PI, 0);
TmfTimestampTransformLinearFast fast2 = fTransformFactory.create(Math.PI, 0);
long deltaMax = fast.getDeltaMax();
long start = (ts - (ts % deltaMax) - 10);
checkTime(fast, fast2, 20, start, 1);
}
use of org.eclipse.tracecompass.internal.tmf.core.synchronization.TmfTimestampTransformLinearFast in project tracecompass by tracecompass.
the class TimestampTransformBenchmark method testCompareTimestampTransformPerformance.
/**
* Benchmark to compare the classic and fast timestamp transform.
*
* Ignore when running automatically, just for local benchmarks.
*/
@Ignore
@Test
public void testCompareTimestampTransformPerformance() {
/*
* We call constructors directly instead of TimestampTransformFactory to
* create properly each transform type.
*/
ITmfTimestampTransform classic = new TmfTimestampTransformLinear(Math.PI, 1234);
ITmfTimestampTransform fast = new TmfTimestampTransformLinearFast(Math.PI, 1234);
doTimestampTransformRun("Linear transform classic", classic, 5);
doTimestampTransformRun("Linear transform fast", fast, 5);
}
Aggregations