use of org.eclipse.tracecompass.internal.tmf.core.synchronization.TmfTimestampTransformLinear 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.TmfTimestampTransformLinear 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.TmfTimestampTransformLinear in project tracecompass by tracecompass.
the class TsTransformTest method testEquality.
/**
* Test hash and equals function
*/
@Test
public void testEquality() {
Map<ITmfTimestampTransform, String> map = new HashMap<>();
ITmfTimestampTransform ttl = new TmfTimestampTransformLinear(BigDecimal.valueOf(2.0), BigDecimal.valueOf(3));
ITmfTimestampTransform ttl2 = new TmfTimestampTransformLinear(BigDecimal.valueOf(2.0), BigDecimal.valueOf(3));
ITmfTimestampTransform ttl3 = new TmfTimestampTransformLinear(BigDecimal.valueOf(3), BigDecimal.valueOf(3));
assertEquals(ttl, ttl2);
assertFalse(ttl.equals(ttl3));
assertFalse(ttl2.equals(ttl3));
map.put(ttl, "a");
assertTrue(map.containsKey(ttl2));
assertEquals("a", map.get(ttl));
ITmfTimestampTransform ti = TmfTimestampTransform.IDENTITY;
assertEquals(TmfTimestampTransform.IDENTITY, ti);
assertFalse(TmfTimestampTransform.IDENTITY.equals(ttl));
map.put(ti, "b");
assertTrue(map.containsKey(TmfTimestampTransform.IDENTITY));
assertEquals("b", map.get(ti));
assertFalse(ti.equals(ttl));
assertFalse(ttl.equals(ti));
}
use of org.eclipse.tracecompass.internal.tmf.core.synchronization.TmfTimestampTransformLinear in project tracecompass by tracecompass.
the class TsTransformTest method testComposition.
/**
* Test the transform composition function
*/
@Test
public void testComposition() {
long t = 100;
ITmfTimestampTransform ti = TmfTimestampTransform.IDENTITY;
ITmfTimestampTransform ttl = new TmfTimestampTransformLinear(BigDecimal.valueOf(2.0), BigDecimal.valueOf(3));
ITmfTimestampTransform ttl2 = new TmfTimestampTransformLinear(BigDecimal.valueOf(1.5), BigDecimal.valueOf(8));
ITmfTimestampTransform tc1 = ti.composeWith(ttl);
/* Should be ttl */
assertEquals(ttl, tc1);
assertEquals(203, tc1.transform(t));
tc1 = ttl.composeWith(ti);
/* Should be ttl also */
assertEquals(ttl, tc1);
assertEquals(203, tc1.transform(t));
tc1 = ti.composeWith(ti);
/* Should be identity */
assertEquals(tc1, TmfTimestampTransform.IDENTITY);
assertEquals(100, tc1.transform(t));
tc1 = ttl.composeWith(ttl2);
assertEquals(ttl.transform(ttl2.transform(t)), tc1.transform(t));
assertEquals(319, tc1.transform(t));
tc1 = ttl2.composeWith(ttl);
assertEquals(ttl2.transform(ttl.transform(t)), tc1.transform(t));
assertEquals(312, tc1.transform(t));
}
use of org.eclipse.tracecompass.internal.tmf.core.synchronization.TmfTimestampTransformLinear 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