Search in sources :

Example 1 with ITmfTimestampTransform

use of org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform in project tracecompass by tracecompass.

the class ExperimentSyncTest method testDjangoExperimentSync.

/**
 * Testing synchronization with 3 traces, one of which synchronizes with
 * both other
 */
@Test
public void testDjangoExperimentSync() {
    CtfTmfTrace trace1 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.DJANGO_CLIENT);
    CtfTmfTrace trace2 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.DJANGO_DB);
    CtfTmfTrace trace3 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.DJANGO_HTTPD);
    ITmfTrace[] traces = { trace1, trace2, trace3 };
    TmfExperiment experiment = new TmfExperiment(traces[0].getEventType(), EXPERIMENT, traces, BLOCK_SIZE, null);
    SynchronizationAlgorithm syncAlgo = experiment.synchronizeTraces(true);
    ITmfTimestampTransform tt1 = syncAlgo.getTimestampTransform(trace1);
    ITmfTimestampTransform tt2 = syncAlgo.getTimestampTransform(trace2);
    ITmfTimestampTransform tt3 = syncAlgo.getTimestampTransform(trace3);
    trace1.setTimestampTransform(tt1);
    trace2.setTimestampTransform(tt2);
    trace3.setTimestampTransform(tt3);
    assertEquals(TimestampTransformFactory.getDefaultTransform(), tt1);
    assertEquals("TmfTimestampTransformLinearFast [ slope = 0.9999996313017589597204633828681240, offset = 498490309972.0038068817738527724192 ]", tt2.toString());
    assertEquals("TmfTimestampTransformLinearFast [ slope = 1.000000119014882262265342419815932, offset = -166652893534.6189900382736187431134 ]", tt3.toString());
    experiment.dispose();
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) ITmfTimestampTransform(org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform) CtfTmfTrace(org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace) SynchronizationAlgorithm(org.eclipse.tracecompass.tmf.core.synchronization.SynchronizationAlgorithm) Test(org.junit.Test)

Example 2 with ITmfTimestampTransform

use of org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform 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);
}
Also used : TmfTimestampTransformLinearFast(org.eclipse.tracecompass.internal.tmf.core.synchronization.TmfTimestampTransformLinearFast) ITmfTimestampTransform(org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform) SynchronizationAlgorithm(org.eclipse.tracecompass.tmf.core.synchronization.SynchronizationAlgorithm) Test(org.junit.Test)

Example 3 with ITmfTimestampTransform

use of org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform in project tracecompass by tracecompass.

the class TimeOffsetTest method testClearOffset.

@Test
public void testClearOffset() throws TmfTraceException {
    ITmfTimestampTransform tt = TimestampTransformFactory.createWithOffset(ONE_MS);
    TimestampTransformFactory.setTimestampTransform(fResource, tt);
    TimestampTransformFactory.setTimestampTransform(fResource, null);
    ITmfTrace trace = createAndIndexTrace();
    final TmfContext context = (TmfContext) trace.seekEvent(0);
    ITmfEvent event = trace.getNext(context);
    assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
    event = trace.getNext(context);
    assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
    trace.dispose();
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfContext(org.eclipse.tracecompass.tmf.core.trace.TmfContext) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) ITmfTimestampTransform(org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform) Test(org.junit.Test)

Example 4 with ITmfTimestampTransform

use of org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform 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));
}
Also used : TmfTimestampTransformLinear(org.eclipse.tracecompass.internal.tmf.core.synchronization.TmfTimestampTransformLinear) HashMap(java.util.HashMap) ITmfTimestampTransform(org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform) Test(org.junit.Test)

Example 5 with ITmfTimestampTransform

use of org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform in project tracecompass by tracecompass.

the class TsTransformTest method testEqualityConstantTransform.

/**
 * Test the equality of {@link TmfConstantTransform} objects.
 */
@Test
public void testEqualityConstantTransform() {
    ITmfTimestampTransform tt1 = new TmfConstantTransform(50L);
    ITmfTimestampTransform tt2 = new TmfConstantTransform(50L);
    ITmfTimestampTransform tt3 = new TmfConstantTransform(-10L);
    assertEquals(tt1, tt2);
    assertNotEquals(tt1, tt3);
    assertNotEquals(tt2, tt3);
}
Also used : TmfConstantTransform(org.eclipse.tracecompass.internal.tmf.core.synchronization.TmfConstantTransform) ITmfTimestampTransform(org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform) Test(org.junit.Test)

Aggregations

ITmfTimestampTransform (org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform)20 Test (org.junit.Test)17 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)7 SynchronizationAlgorithm (org.eclipse.tracecompass.tmf.core.synchronization.SynchronizationAlgorithm)5 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)4 TmfTimestampTransformLinear (org.eclipse.tracecompass.internal.tmf.core.synchronization.TmfTimestampTransformLinear)3 TmfContext (org.eclipse.tracecompass.tmf.core.trace.TmfContext)3 File (java.io.File)2 SyncAlgorithmFullyIncremental (org.eclipse.tracecompass.internal.tmf.core.synchronization.SyncAlgorithmFullyIncremental)2 TmfConstantTransform (org.eclipse.tracecompass.internal.tmf.core.synchronization.TmfConstantTransform)2 TmfTimestampTransformLinearFast (org.eclipse.tracecompass.internal.tmf.core.synchronization.TmfTimestampTransformLinearFast)2 TmfExperiment (org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment)2 HashMultimap (com.google.common.collect.HashMultimap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Multimap (com.google.common.collect.Multimap)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1