Search in sources :

Example 11 with ITmfTimestampTransform

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

the class TimestampTransformBenchmark method testTimestampTransformPerformance.

/**
 * Test the timestamp transform performances
 */
@Test
public void testTimestampTransformPerformance() {
    ITmfTimestampTransform transform = TimestampTransformFactory.getDefaultTransform();
    doTimestampTransformRun("Identity transform", transform, 10);
    transform = TimestampTransformFactory.createWithOffset(123456789);
    doTimestampTransformRun("Transform with offset", transform, 10);
    transform = TimestampTransformFactory.createLinear(Math.PI, 1234);
    doTimestampTransformRun("Linear transform", transform, 5);
    transform = TimestampTransformFactory.createLinear(10000.1234545565635, -4312278758437L);
    doTimestampTransformRun("Linear transform with larger slope and negative offset", transform, 5);
}
Also used : ITmfTimestampTransform(org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform) Test(org.junit.Test)

Example 12 with ITmfTimestampTransform

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

the class TimeOffsetTest method testPositiveOffset.

@Test
public void testPositiveOffset() throws TmfTraceException {
    ITmfTimestampTransform tt = TimestampTransformFactory.createWithOffset(ONE_MS);
    TimestampTransformFactory.setTimestampTransform(fResource, tt);
    ITmfTrace trace = createAndIndexTrace();
    final TmfContext context = (TmfContext) trace.seekEvent(0);
    ITmfEvent event = trace.getNext(context);
    assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
    event = trace.getNext(context);
    assertEquals("Event timestamp", 3, 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 13 with ITmfTimestampTransform

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

the class TimeOffsetTest method testNegativeOffset.

@Test
public void testNegativeOffset() throws TmfTraceException {
    ITmfTimestampTransform tt = TimestampTransformFactory.createWithOffset(-ONE_MS);
    TimestampTransformFactory.setTimestampTransform(fResource, tt);
    ITmfTrace trace = createAndIndexTrace();
    final TmfContext context = (TmfContext) trace.seekEvent(0);
    ITmfEvent event = trace.getNext(context);
    assertEquals("Event timestamp", 0, event.getTimestamp().getValue());
    event = trace.getNext(context);
    assertEquals("Event timestamp", 1, 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 14 with ITmfTimestampTransform

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

the class TsTransformFactoryTest method transformSlope.

/**
 * Test with a slope
 */
@Test
public void transformSlope() {
    final ITmfTimestampTransform slope = TimestampTransformFactory.createLinear(10, 0);
    final ITmfTimestampTransform slope1 = TimestampTransformFactory.createLinear(10.0, TmfTimestamp.fromNanos(0));
    assertEquals(t1e3, slope.transform(t1e2));
    assertEquals(tn100, slope.transform(TmfTimestamp.fromNanos(10)));
    assertEquals(tn100, slope.transform(slope.transform(tn1)));
    assertEquals(tn100, slope.composeWith(slope).transform(tn1));
    assertEquals(tn100, slope1.transform(TmfTimestamp.fromNanos(10)));
}
Also used : ITmfTimestampTransform(org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform) Test(org.junit.Test)

Example 15 with ITmfTimestampTransform

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

the class TsTransformFactoryTest method transformOffset.

/**
 * Test with an offset of 100
 */
@Test
public void transformOffset() {
    final ITmfTimestampTransform offset = offset1;
    final ITmfTimestampTransform compositeTransform = offset.composeWith(TimestampTransformFactory.createWithOffset(TmfTimestamp.fromNanos(-100)));
    assertEquals(tn100, offset.transform(t0));
    assertEquals(tn100, offset.transform(tn0));
    assertEquals(tn0, compositeTransform.transform(tn0));
    assertEquals(t0, compositeTransform.transform(t0));
    assertEquals(200, offset1.transform(100));
    assertEquals(200, offset2.transform(100));
    assertEquals(200, offset3.transform(100));
    assertEquals(200, offset4.transform(100));
}
Also used : 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