Often times, a TmfTimestamp will be created using a scale of -9 or 0.
The result is a less efficient timestamp that takes more memory than
the nano or simple timestamp and is slower to compare. This patch makes
timestamps created always return the more efficient type.
At the moment, the factory will either create a new TmfNanoTimestamp if the
scale is NANOSECOND_SCALE, TmfSecondTimestamp if the scale is SECOND_SCALE,
or a plain old TmfTimestamp (TmfRealTimestamp).
This patch adds the following helper methods:
* create(value, scale) - create a timestamp with an arbitrary scale and value
* fromNanos(value) - create a nanosecond based timestamp (more efficient)
* fromMicros(value) - create a microsecond based timestamp
* fromMillis(value) - create a millisecond based timestamp
* fromSeconds(value) - create a second based timestamp (more efficient)
Also, TmfTimestamp is converted to an abstract class with "getScale()" and
"getValue()" needing to be implemented. This allows a timestamp like
TmfNanoTimestamp or TmfSecondTimestamp to not store an extra integer and
save 33% of their sizes.
Change-Id: I0996c9b4f626a70436b58e82446ed69d2e50af98
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/65312
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-by: Hudson CI
vertices[i] = v;
fGraph.append(WORKER1, v);
}
- assertEquals(vertices[0], fGraph.getVertexAt(new TmfTimestamp(5), WORKER1));
- assertEquals(vertices[0], fGraph.getVertexAt(new TmfTimestamp(0), WORKER1));
- assertEquals(vertices[1], fGraph.getVertexAt(new TmfTimestamp(6), WORKER1));
- assertEquals(vertices[3], fGraph.getVertexAt(new TmfTimestamp(19), WORKER1));
- assertNull(fGraph.getVertexAt(new TmfTimestamp(19), WORKER2));
- assertEquals(vertices[3], fGraph.getVertexAt(new TmfTimestamp(20), WORKER1));
- assertEquals(vertices[4], fGraph.getVertexAt(new TmfTimestamp(21), WORKER1));
- assertNull(fGraph.getVertexAt(new TmfTimestamp(26), WORKER1));
+ assertEquals(vertices[0], fGraph.getVertexAt(TmfTimestamp.fromSeconds(5), WORKER1));
+ assertEquals(vertices[0], fGraph.getVertexAt(TmfTimestamp.fromSeconds(0), WORKER1));
+ assertEquals(vertices[1], fGraph.getVertexAt(TmfTimestamp.fromSeconds(6), WORKER1));
+ assertEquals(vertices[3], fGraph.getVertexAt(TmfTimestamp.fromSeconds(19), WORKER1));
+ assertNull(fGraph.getVertexAt(TmfTimestamp.fromSeconds(19), WORKER2));
+ assertEquals(vertices[3], fGraph.getVertexAt(TmfTimestamp.fromSeconds(20), WORKER1));
+ assertEquals(vertices[4], fGraph.getVertexAt(TmfTimestamp.fromSeconds(21), WORKER1));
+ assertNull(fGraph.getVertexAt(TmfTimestamp.fromSeconds(26), WORKER1));
}
/**
package org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests.latency;
import static org.eclipse.swtbot.swt.finder.SWTBotAssert.assertVisible;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.IOException;
import java.lang.reflect.Field;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.AnalysisTimingImageConstants;
import org.eclipse.tracecompass.common.core.NonNullUtils;
-import org.swtchart.Range;
import org.eclipse.tracecompass.internal.analysis.timing.ui.Activator;
+import org.swtchart.Range;
/**
* Zoom action for the density view
import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
@Override
public void widgetSelected(@Nullable SelectionEvent e) {
ISegment selectedSegment = ((ISegment) NonNullUtils.checkNotNull(e).item.getData());
- ITmfTimestamp start = new TmfNanoTimestamp(selectedSegment.getStart());
- ITmfTimestamp end = new TmfNanoTimestamp(selectedSegment.getEnd());
+ ITmfTimestamp start = TmfTimestamp.fromNanos(selectedSegment.getStart());
+ ITmfTimestamp end = TmfTimestamp.fromNanos(selectedSegment.getEnd());
TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(AbstractSegmentStoreTableViewer.this, start, end));
}
}
IAction gotoStartTime = new Action(Messages.SegmentStoreTableViewer_goToStartEvent) {
@Override
public void run() {
- broadcast(new TmfSelectionRangeUpdatedSignal(AbstractSegmentStoreTableViewer.this, new TmfNanoTimestamp(segment.getStart())));
+ broadcast(new TmfSelectionRangeUpdatedSignal(AbstractSegmentStoreTableViewer.this, TmfTimestamp.fromNanos(segment.getStart())));
}
};
IAction gotoEndTime = new Action(Messages.SegmentStoreTableViewer_goToEndEvent) {
@Override
public void run() {
- broadcast(new TmfSelectionRangeUpdatedSignal(AbstractSegmentStoreTableViewer.this, new TmfNanoTimestamp(segment.getEnd())));
+ broadcast(new TmfSelectionRangeUpdatedSignal(AbstractSegmentStoreTableViewer.this, TmfTimestamp.fromNanos(segment.getEnd())));
}
};
import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.ITmfChartTimeProvider;
import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.TmfClosestDataPointTooltipProvider;
if ((xS != null) && (yS != null) && (dataIndex < xS.length) && (dataIndex < yS.length)) {
StringBuffer buffer = new StringBuffer();
buffer.append(checkNotNull(Messages.SegmentStoreScatterGraphViewer_xAxis)).append('=');
- buffer.append(new TmfTimestamp((long) xS[dataIndex] + getChartViewer().getTimeOffset(), ITmfTimestamp.NANOSECOND_SCALE).toString());
+ buffer.append(TmfTimestamp.fromNanos((long) xS[dataIndex] + getChartViewer().getTimeOffset()).toString());
buffer.append('\n');
buffer.append(Messages.SegmentStoreScatterGraphViewer_yAxis).append('=');
buffer.append((long) yS[dataIndex]);
*******************************************************************************/
package org.eclipse.tracecompass.btf.core.tests.trace;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.util.Map;
* @return TmfTimestamp with proper scale
*/
public @NonNull ITmfTimestamp createTimestamp(long timestamp) {
- return new TmfTimestamp(timestamp, fScale);
+ return TmfTimestamp.create(timestamp, fScale);
}
}
package org.eclipse.tracecompass.ctf.core.tests.trace;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import java.io.File;
import java.io.FileNotFoundException;
package org.eclipse.tracecompass.ctf.core.tests.types;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotNull;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
package org.eclipse.tracecompass.ctf.parser;
-import org.antlr.runtime.*;
-import java.util.Stack;
-import java.util.List;
-import java.util.ArrayList;
+import org.antlr.runtime.BaseRecognizer;
+import org.antlr.runtime.CharStream;
+import org.antlr.runtime.DFA;
+import org.antlr.runtime.EarlyExitException;
+import org.antlr.runtime.Lexer;
+import org.antlr.runtime.MismatchedSetException;
+import org.antlr.runtime.NoViableAltException;
+import org.antlr.runtime.RecognitionException;
+import org.antlr.runtime.RecognizerSharedState;
@SuppressWarnings("all")
public class CTFLexer extends Lexer {
package org.eclipse.tracecompass.ctf.parser;
-import java.util.Set;
import java.util.HashSet;
-
-
-import org.antlr.runtime.*;
+import java.util.Set;
import java.util.Stack;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.HashMap;
-import org.antlr.runtime.tree.*;
+import org.antlr.runtime.BaseRecognizer;
+import org.antlr.runtime.BitSet;
+import org.antlr.runtime.DFA;
+import org.antlr.runtime.EarlyExitException;
+import org.antlr.runtime.FailedPredicateException;
+import org.antlr.runtime.IntStream;
+import org.antlr.runtime.MismatchedSetException;
+import org.antlr.runtime.MismatchedTokenException;
+import org.antlr.runtime.NoViableAltException;
+import org.antlr.runtime.Parser;
+import org.antlr.runtime.ParserRuleReturnScope;
+import org.antlr.runtime.RecognitionException;
+import org.antlr.runtime.RecognizerSharedState;
+import org.antlr.runtime.Token;
+import org.antlr.runtime.TokenStream;
+import org.antlr.runtime.tree.CommonTree;
+import org.antlr.runtime.tree.CommonTreeAdaptor;
+import org.antlr.runtime.tree.RewriteEarlyExitException;
+import org.antlr.runtime.tree.RewriteRuleSubtreeStream;
+import org.antlr.runtime.tree.RewriteRuleTokenStream;
+import org.antlr.runtime.tree.TreeAdaptor;
@SuppressWarnings("all")
*/
@Test
public void testCtfLocation_timestamp() {
- ITmfTimestamp timestamp = new TmfTimestamp();
+ ITmfTimestamp timestamp = TmfTimestamp.fromSeconds(0);
CtfLocation result = new CtfLocation(timestamp);
assertNotNull(result);
import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest;
import org.eclipse.tracecompass.tmf.core.synchronization.TimestampTransformFactory;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils;
public void testFirstLostEvent() {
final long rank = 190;
final long startTime = 1376592664828900165L;
- final ITmfTimestamp start = new TmfNanoTimestamp(startTime);
- final ITmfTimestamp end = new TmfNanoTimestamp(startTime + 502911L);
+ final ITmfTimestamp start = TmfTimestamp.fromNanos(startTime);
+ final ITmfTimestamp end = TmfTimestamp.fromNanos(startTime + 502911L);
final long nbLost = 859;
validateLostEvent(rank, start, end, nbLost);
public void testSecondLostEvent() {
final long rank = 229;
final long startTime = 1376592664829477058L;
- final ITmfTimestamp start = new TmfNanoTimestamp(startTime);
- final ITmfTimestamp end = new TmfNanoTimestamp(startTime + 347456L);
+ final ITmfTimestamp start = TmfTimestamp.fromNanos(startTime);
+ final ITmfTimestamp end = TmfTimestamp.fromNanos(startTime + 347456L);
final long nbLost = 488;
validateLostEvent(rank, start, end, nbLost);
@Test
public void testNormalEvent() {
final long rank = 200;
- final ITmfTimestamp ts = new TmfNanoTimestamp(1376592664829425780L);
+ final ITmfTimestamp ts = TmfTimestamp.fromNanos(1376592664829425780L);
final CtfTmfEvent event = getOneEventTime(ts);
/* Make sure seeking by rank yields the same event */
trace.indexTrace(true);
final long rank = 190;
- final ITmfTimestamp start = new TmfNanoTimestamp(1376592664828900165L + offset);
- final ITmfTimestamp end = new TmfNanoTimestamp(1376592664828900165L + 502911L + offset);
+ final ITmfTimestamp start = TmfTimestamp.fromNanos(1376592664828900165L + offset);
+ final ITmfTimestamp end = TmfTimestamp.fromNanos(1376592664828900165L + 502911L + offset);
final long nbLost = 859;
ITmfContext context = trace.seekEvent(rank);
import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
public EventContextTestRequest(long timestamp) {
super(CtfTmfEvent.class,
- new TmfTimeRange(new TmfNanoTimestamp(timestamp), TmfTimestamp.BIG_CRUNCH),
+ new TmfTimeRange(TmfTimestamp.fromNanos(timestamp), TmfTimestamp.BIG_CRUNCH),
0, 1, ExecutionType.FOREGROUND);
}
import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest;
import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest;
import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
-import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils;
/** Time-out tests after 60 seconds */
@Rule
- public TestRule globalTimeout= new Timeout(1, TimeUnit.MINUTES);
+ public TestRule globalTimeout = new Timeout(1, TimeUnit.MINUTES);
// ------------------------------------------------------------------------
// Constants
long foregroundStartTime = fStartTime + ((fEndTime - fStartTime) / 4);
long foregroundEndTime = fStartTime + ((fEndTime - fStartTime) / 2);
- fForegroundTimeRange = new TmfTimeRange(new TmfTimestamp(foregroundStartTime, ITmfTimestamp.NANOSECOND_SCALE),
- new TmfTimestamp(foregroundEndTime, ITmfTimestamp.NANOSECOND_SCALE));
+ fForegroundTimeRange = new TmfTimeRange(TmfTimestamp.fromNanos(foregroundStartTime),
+ TmfTimestamp.fromNanos(foregroundEndTime));
}
/**
ForegroundRequest foreground3 = new ForegroundRequest(TmfTimeRange.ETERNITY);
fixture.sendRequest(foreground3);
- TmfSelectionRangeUpdatedSignal signal3 = new TmfSelectionRangeUpdatedSignal(this, new TmfTimestamp(fForegroundTimeRange.getStartTime()));
+ TmfSelectionRangeUpdatedSignal signal3 = new TmfSelectionRangeUpdatedSignal(this, fForegroundTimeRange.getStartTime());
fixture.broadcast(signal3);
try {
public void TestMultiRequest4() {
ForegroundRequest foreground4 = new ForegroundRequest(fForegroundTimeRange);
fixture.sendRequest(foreground4);
- TmfSelectionRangeUpdatedSignal signal4 = new TmfSelectionRangeUpdatedSignal(this, new TmfTimestamp(fStartTime + ((fEndTime - fStartTime) / 8)));
+ TmfSelectionRangeUpdatedSignal signal4 = new TmfSelectionRangeUpdatedSignal(this, TmfTimestamp.fromSeconds(fStartTime + ((fEndTime - fStartTime) / 8)));
fixture.broadcast(signal4);
try {
public void TestMultiRequest5() {
ForegroundRequest foreground5 = new ForegroundRequest(fForegroundTimeRange);
fixture.sendRequest(foreground5);
- TmfSelectionRangeUpdatedSignal signal5 = new TmfSelectionRangeUpdatedSignal(this, new TmfTimestamp(fEndTime - ((fEndTime - fStartTime) / 4)));
+ TmfSelectionRangeUpdatedSignal signal5 = new TmfSelectionRangeUpdatedSignal(this, TmfTimestamp.fromSeconds(fEndTime - ((fEndTime - fStartTime) / 4)));
fixture.broadcast(signal5);
try {
fixture.sendRequest(background6);
fixture.sendRequest(foreground6);
- TmfSelectionRangeUpdatedSignal signal6 = new TmfSelectionRangeUpdatedSignal(this, new TmfTimestamp(fStartTime + ((fEndTime - fStartTime) / 8)));
+ TmfSelectionRangeUpdatedSignal signal6 = new TmfSelectionRangeUpdatedSignal(this, TmfTimestamp.fromSeconds(fStartTime + ((fEndTime - fStartTime) / 8)));
fixture.broadcast(signal6);
try {
@Test
public void preemptedForegroundRequest() {
ForegroundRequest foreground9 = new ForegroundRequest(TmfTimeRange.ETERNITY);
- TmfTimeRange shortTimeRange = new TmfTimeRange(new TmfTimestamp(fStartTime, ITmfTimestamp.NANOSECOND_SCALE),
- new TmfTimestamp(fStartTime + ((fEndTime - fStartTime) / 16), ITmfTimestamp.NANOSECOND_SCALE));
+ TmfTimeRange shortTimeRange = new TmfTimeRange(TmfTimestamp.fromNanos(fStartTime),
+ TmfTimestamp.fromNanos(fStartTime + ((fEndTime - fStartTime) / 16)));
ForegroundRequest shortForeground = new ForegroundRequest(shortTimeRange);
fixture.sendRequest(foreground9);
try {
@Rule
public TestRule globalTimeout = new Timeout(1, TimeUnit.MINUTES);
- private static final int SCALE = ITmfTimestamp.NANOSECOND_SCALE;
-
private static ITmfTrace trace1;
private static final long t1start = 1331668247314038062L;
private static final long t1end = 1331668259054285979L;
@Test
public void testNewTimestamp() {
openTrace(trace2);
- ITmfTimestamp ts = new TmfTimestamp(t2start + ONE_SECOND, SCALE);
+ ITmfTimestamp ts = TmfTimestamp.fromNanos(t2start + ONE_SECOND);
selectTimestamp(ts);
TmfTimeRange selection = tm.getCurrentTraceContext().getSelectionRange();
public void testTimestampBefore() {
openTrace(trace2);
TmfTimeRange beforeTr = tm.getCurrentTraceContext().getSelectionRange();
- ITmfTimestamp ts = new TmfTimestamp(t2start - ONE_SECOND, SCALE);
+ ITmfTimestamp ts = TmfTimestamp.fromNanos(t2start - ONE_SECOND);
selectTimestamp(ts);
TmfTimeRange selection = tm.getCurrentTraceContext().getSelectionRange();
public void testTimestampAfter() {
openTrace(trace2);
TmfTimeRange beforeTr = tm.getCurrentTraceContext().getSelectionRange();
- ITmfTimestamp ts = new TmfTimestamp(t2end + ONE_SECOND, SCALE);
+ ITmfTimestamp ts = TmfTimestamp.fromNanos(t2end + ONE_SECOND);
selectTimestamp(ts);
TmfTimeRange selection = tm.getCurrentTraceContext().getSelectionRange();
public void testTraceNewTimeRange() {
openTrace(trace2);
TmfTimeRange range = new TmfTimeRange(
- new TmfTimestamp(t2start + ONE_SECOND, SCALE),
- new TmfTimestamp(t2end - ONE_SECOND, SCALE));
+ TmfTimestamp.fromNanos(t2start + ONE_SECOND),
+ TmfTimestamp.fromNanos(t2end - ONE_SECOND));
selectWindowRange(range);
TmfTimeRange curRange = tm.getCurrentTraceContext().getWindowRange();
public void testTraceTimeRangeClampingStart() {
openTrace(trace2);
TmfTimeRange range = new TmfTimeRange(
- new TmfTimestamp(t2start - ONE_SECOND, SCALE), // minus here
- new TmfTimestamp(t2end - ONE_SECOND, SCALE));
+ TmfTimestamp.fromNanos(t2start - ONE_SECOND), // minus here
+ TmfTimestamp.fromNanos(t2end - ONE_SECOND));
selectWindowRange(range);
TmfTimeRange curRange = tm.getCurrentTraceContext().getWindowRange();
public void testTraceTimeRangeClampingEnd() {
openTrace(trace2);
TmfTimeRange range = new TmfTimeRange(
- new TmfTimestamp(t2start + ONE_SECOND, SCALE),
- new TmfTimestamp(t2end + ONE_SECOND, SCALE)); // plus here
+ TmfTimestamp.fromNanos(t2start + ONE_SECOND),
+ TmfTimestamp.fromNanos(t2end + ONE_SECOND)); // plus here
selectWindowRange(range);
TmfTimeRange curRange = tm.getCurrentTraceContext().getWindowRange();
public void testTraceTimeRangeClampingBoth() {
openTrace(trace2);
TmfTimeRange range = new TmfTimeRange(
- new TmfTimestamp(t2start - ONE_SECOND, SCALE), // minus here
- new TmfTimestamp(t2end + ONE_SECOND, SCALE)); // plus here
+ TmfTimestamp.fromNanos(t2start - ONE_SECOND), // minus here
+ TmfTimestamp.fromNanos(t2end + ONE_SECOND)); // plus here
selectWindowRange(range);
TmfTimeRange curRange = tm.getCurrentTraceContext().getWindowRange();
openTrace(trace1);
openTrace(trace2);
selectTrace(trace1);
- TmfTimestamp ts = new TmfTimestamp(t1start + ONE_SECOND, SCALE);
+ ITmfTimestamp ts = TmfTimestamp.fromNanos(t1start + ONE_SECOND);
selectTimestamp(ts);
/* Timestamp of trace1 should have been updated */
openTrace(trace1);
openTrace(trace2);
selectTrace(trace1);
- TmfTimestamp ts = new TmfTimestamp(t1end + ONE_SECOND, SCALE);
+ ITmfTimestamp ts = TmfTimestamp.fromNanos(t1end + ONE_SECOND);
selectTimestamp(ts);
/* Timestamp of trace1 should not have changed */
openTrace(trace1);
openTrace(trace2);
selectTrace(trace1);
- TmfTimestamp ts = new TmfTimestamp(t2end + ONE_SECOND, SCALE);
+ ITmfTimestamp ts = TmfTimestamp.fromNanos(t2end + ONE_SECOND);
selectTimestamp(ts);
/* Timestamp of trace1 should not have changed */
openTrace(trace2);
selectTrace(trace1);
TmfTimeRange range = new TmfTimeRange(
- new TmfTimestamp(t1start + ONE_SECOND, SCALE),
- new TmfTimestamp(t1end - ONE_SECOND, SCALE));
+ TmfTimestamp.fromNanos(t1start + ONE_SECOND),
+ TmfTimestamp.fromNanos(t1end - ONE_SECOND));
selectWindowRange(range);
/* Range of trace1 should be equal to the requested one */
openTrace(trace2);
selectTrace(trace1);
TmfTimeRange range = new TmfTimeRange(
- new TmfTimestamp(t1start + ONE_SECOND, SCALE),
- new TmfTimestamp(t1end + ONE_SECOND, SCALE));
+ TmfTimestamp.fromNanos(t1start + ONE_SECOND),
+ TmfTimestamp.fromNanos(t1end + ONE_SECOND));
selectWindowRange(range);
/* Range of trace1 should get clamped to its end time */
TmfTimeRange expectedRange = new TmfTimeRange(
- new TmfTimestamp(t1start + ONE_SECOND, SCALE),
- new TmfTimestamp(t1end, SCALE));
+ TmfTimestamp.fromNanos(t1start + ONE_SECOND),
+ TmfTimestamp.fromNanos(t1end));
assertEquals(expectedRange, tm.getCurrentTraceContext().getWindowRange());
/* Range of trace2 should not have changed */
openTrace(trace2);
selectTrace(trace1);
TmfTimeRange range = new TmfTimeRange(
- new TmfTimestamp(t1end - ONE_SECOND, SCALE),
- new TmfTimestamp(t2start + ONE_SECOND, SCALE));
+ TmfTimestamp.fromNanos(t1end - ONE_SECOND),
+ TmfTimestamp.fromNanos(t2start + ONE_SECOND));
selectWindowRange(range);
/* Range of trace1 should be clamped to its end time */
TmfTimeRange expectedRange = new TmfTimeRange(
- new TmfTimestamp(t1end - ONE_SECOND, SCALE),
- new TmfTimestamp(t1end, SCALE));
+ TmfTimestamp.fromNanos(t1end - ONE_SECOND),
+ TmfTimestamp.fromNanos(t1end));
assertEquals(expectedRange, tm.getCurrentTraceContext().getWindowRange());
/* Range of trace2 should be clamped to its start time */
selectTrace(trace2);
expectedRange = new TmfTimeRange(
- new TmfTimestamp(t2start, SCALE),
- new TmfTimestamp(t2start + ONE_SECOND, SCALE));
+ TmfTimestamp.fromNanos(t2start),
+ TmfTimestamp.fromNanos(t2start + ONE_SECOND));
assertEquals(expectedRange, tm.getCurrentTraceContext().getWindowRange());
}
openTrace(trace2);
selectTrace(trace1);
TmfTimeRange range = new TmfTimeRange(
- new TmfTimestamp(t1end + ONE_SECOND, SCALE),
- new TmfTimestamp(t1end - ONE_SECOND, SCALE));
+ TmfTimestamp.fromNanos(t1end + ONE_SECOND),
+ TmfTimestamp.fromNanos(t1end - ONE_SECOND));
selectWindowRange(range);
/* Range of trace1 should not have changed */
public void testExperimentTimestampInTrace() {
TmfExperiment exp = createExperiment(trace1, trace2);
openTrace(exp);
- TmfTimestamp ts = new TmfTimestamp(t1start + ONE_SECOND, SCALE);
+ ITmfTimestamp ts = TmfTimestamp.fromNanos(t1start + ONE_SECOND);
selectTimestamp(ts);
/* The experiment's current time should be updated. */
public void testExperimentTimestampInBetween() {
TmfExperiment exp = createExperiment(trace1, trace2);
openTrace(exp);
- TmfTimestamp ts = new TmfTimestamp(t1end + ONE_SECOND, SCALE);
+ ITmfTimestamp ts = TmfTimestamp.fromNanos(t1end + ONE_SECOND);
selectTimestamp(ts);
/* The experiment's current time should be updated. */
public void testExperimentTimestampInvalid() {
TmfExperiment exp = createExperiment(trace1, trace2);
openTrace(exp);
- TmfTimestamp ts = new TmfTimestamp(t2end + ONE_SECOND, SCALE);
+ ITmfTimestamp ts = TmfTimestamp.fromNanos(t2end + ONE_SECOND);
selectTimestamp(ts);
/* The experiment's current time should NOT be updated. */
openTrace(exp);
final TmfTimeRange range = new TmfTimeRange(
- new TmfTimestamp(t1start - ONE_SECOND, SCALE),
- new TmfTimestamp(t1end - ONE_SECOND, SCALE));
+ TmfTimestamp.fromNanos(t1start - ONE_SECOND),
+ TmfTimestamp.fromNanos(t1end - ONE_SECOND));
selectWindowRange(range);
TmfTimeRange actualRange = tm.getCurrentTraceContext().getWindowRange();
openTrace(exp);
final TmfTimeRange range = new TmfTimeRange(
- new TmfTimestamp(t1start - ONE_SECOND, SCALE),
- new TmfTimestamp(t2end + ONE_SECOND, SCALE));
+ TmfTimestamp.fromNanos(t1start - ONE_SECOND),
+ TmfTimestamp.fromNanos(t2end + ONE_SECOND));
selectWindowRange(range);
TmfTimeRange actualRange = tm.getCurrentTraceContext().getWindowRange();
openTrace(exp);
final TmfTimeRange range = new TmfTimeRange(
- new TmfTimestamp(t1end + ONE_SECOND, SCALE),
- new TmfTimestamp(t2start - ONE_SECOND, SCALE));
+ TmfTimestamp.fromNanos(t1end + ONE_SECOND),
+ TmfTimestamp.fromNanos(t2start - ONE_SECOND));
selectWindowRange(range);
TmfTimeRange actualRange = tm.getCurrentTraceContext().getWindowRange();
private static @NonNull ITmfTimestamp calculateOffset(ITmfTimestamp initialTs, ITmfTimestamp offsetTs) {
long start = initialTs.toNanos();
long offset = offsetTs.toNanos();
- return new TmfTimestamp(start + offset, SCALE);
+ return TmfTimestamp.fromNanos(start + offset);
}
}
import org.eclipse.tracecompass.tmf.core.signal.TmfEndSynchSignal;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignal;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
*/
@Test
public void testSeekEventLoc_timetamp() {
- CtfLocation loc = new CtfLocation(new TmfNanoTimestamp(0L));
+ CtfLocation loc = new CtfLocation(TmfTimestamp.fromNanos(0L));
fixture.seekEvent(loc);
assertNotNull(fixture);
}
*/
@Test
public void testSeekEvent_timestamp() {
- ITmfTimestamp timestamp = new TmfTimestamp();
+ ITmfTimestamp timestamp = TmfTimestamp.create(0, ITmfTimestamp.SECOND_SCALE);
ITmfContext result = fixture.seekEvent(timestamp);
assertNotNull(result);
result.dispose();
import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
import org.eclipse.tracecompass.tmf.core.event.lookup.ITmfModelLookup;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.ctf.core.CtfConstants;
import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
*/
protected CtfTmfEvent(CtfTmfTrace trace,
long rank,
- TmfNanoTimestamp timestamp,
+ ITmfTimestamp timestamp,
String channel,
int cpu,
IEventDeclaration declaration,
CtfTmfEvent(CtfTmfTrace trace) {
super(trace,
ITmfContext.UNKNOWN_RANK,
- new TmfNanoTimestamp(-1),
+ TmfTimestamp.fromNanos(-1),
null,
new TmfEventField("", null, new CtfTmfEventField[0])); //$NON-NLS-1$
fSourceCpu = -1;
import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
import org.eclipse.tracecompass.ctf.core.event.types.IDefinition;
import org.eclipse.tracecompass.ctf.core.event.types.IntegerDefinition;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
/* Prepare what to pass to CtfTmfEvent's constructor */
final IEventDeclaration eventDecl = eventDef.getDeclaration();
final long ts = eventDef.getTimestamp();
- final TmfNanoTimestamp timestamp = trace.createTimestamp(trace.timestampCyclesToNanos(ts));
+ final ITmfTimestamp timestamp = trace.createTimestamp(trace.timestampCyclesToNanos(ts));
int sourceCPU = eventDef.getCPU();
IEventDefinition eventDef,
final IEventDeclaration eventDecl,
final long ts,
- final TmfNanoTimestamp timestamp,
+ final ITmfTimestamp timestamp,
int sourceCPU,
String fileName) {
}
long nbLostEvents = ((IntegerDefinition) nbLostEventsDef).getValue();
long duration = ((IntegerDefinition) durationDef).getValue();
- TmfNanoTimestamp timestampEnd = trace.createTimestamp(
+ ITmfTimestamp timestampEnd = trace.createTimestamp(
trace.timestampCyclesToNanos(ts) + duration);
CtfTmfLostEvent lostEvent = new CtfTmfLostEvent(trace,
import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
import org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
* Only the factory should call this method, the cast to
* (TmfNanoTimestamp) should be safe.
*/
- super(trace, rank, (TmfNanoTimestamp) timeRange.getStartTime(), fileName, cpu, declaration, def);
+ super(trace, rank, timeRange.getStartTime(), fileName, cpu, declaration, def);
fTimeRange = timeRange;
fNbLost = nbLost;
}
import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
import org.eclipse.tracecompass.tmf.core.project.model.ITmfPropertiesProvider;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTraceWithPreDefinedEvents;
* @since 1.0
*/
@Override
- public @NonNull TmfNanoTimestamp createTimestamp(long ts) {
- return new TmfNanoTimestamp(getTimestampTransform().transform(ts));
+ public @NonNull ITmfTimestamp createTimestamp(long ts) {
+ return TmfTimestamp.fromNanos(getTimestampTransform().transform(ts));
}
private static int fCheckpointSize = -1;
@Override
public synchronized int getCheckpointSize() {
if (fCheckpointSize == -1) {
- TmfCheckpoint c = new TmfCheckpoint(new TmfNanoTimestamp(0), new CtfLocation(0, 0), 0);
+ TmfCheckpoint c = new TmfCheckpoint(TmfTimestamp.fromNanos(0), new CtfLocation(0, 0), 0);
ByteBuffer b = ByteBuffer.allocate(ITmfCheckpoint.MAX_SERIALIZE_SIZE);
b.clear();
c.serialize(b);
<pre>
private void createFrame() {
//...
- start.setTime(new TmfTimestamp(1000, -3));
- syn1.setTime(new TmfTimestamp(1005, -3));
- synReturn1.setTime(new TmfTimestamp(1050, -3));
- asyn1.setStartTime(new TmfTimestamp(1060, -3));
- asyn1.setEndTime(new TmfTimestamp(1070, -3));
- asynReturn1.setStartTime(new TmfTimestamp(1060, -3));
- asynReturn1.setEndTime(new TmfTimestamp(1070, -3));
+ start.setTime(TmfTimestamp.create(1000, -3));
+ syn1.setTime(TmfTimestamp.create(1005, -3));
+ synReturn1.setTime(TmfTimestamp.create(1050, -3));
+ asyn1.setStartTime(TmfTimestamp.create(1060, -3));
+ asyn1.setEndTime(TmfTimestamp.create(1070, -3));
+ asynReturn1.setStartTime(TmfTimestamp.create(1060, -3));
+ asynReturn1.setEndTime(TmfTimestamp.create(1070, -3));
//...
}
</pre>
/**
* Adaptor to access GDB Tracepoint frames, previously collected and saved in a
- * file by GDB. One instance of this maps to a single DSF-GDB session.
+ * file by GDB. One instance of this maps to a single DSF-GDB session.
* <p>
* This class offers the functions of starting a post-mortem GDB session with a
* tracepoint data file, navigate the data frames and return the data contained
private String fTraceFile = ""; //$NON-NLS-1$
private String sourceLocator = ""; //$NON-NLS-1$
- // To save tracepoints detailed info. The key is the rank of the
+ // To save tracepoints detailed info. The key is the rank of the
// breakpoint (tracepoint is a kind of breakpoint)
- private Map<Integer, MIBreakpointDMData> fTpInfo = new HashMap<>();
+ private Map<Integer, MIBreakpointDMData> fTpInfo = new HashMap<>();
private TmfEventType tmfEventType = new TmfEventType("GDB Tracepoint", TmfEventField.makeRoot(new String[] { "Content" })); //$NON-NLS-1$ //$NON-NLS-2$
* about the launchers or a change in debug context that we might need to
* react-to.
* <p>
+ *
* @author Francois Chouinard
*/
private class DsfGdbPlatformEventListener implements
- ILaunchesListener2, IDebugContextListener {
+ ILaunchesListener2, IDebugContextListener {
/**
*
IDMContext context = (IDMContext) contextObject;
if (context != null) {
String sessionId;
- synchronized(SESSION_LOCK) {
+ synchronized (SESSION_LOCK) {
sessionId = context.getSessionId();
if (sessionId.equals(fCurrentSessionId)) {
return;
final ICommandControlService commandControl = tracker.getService(ICommandControlService.class);
if (traceControl != null && commandControl != null) {
ITraceTargetDMContext traceContext = (ITraceTargetDMContext) commandControl.getContext();
- traceControl.getCurrentTraceRecordContext(traceContext, queryRm);
+ traceControl.getCurrentTraceRecordContext(traceContext, queryRm);
} else {
queryRm.done();
}
return fNumberOfFrames;
}
-
/**
* Wrapper around the selecting of a frame and the reading of its
* information. this is a work-around for the potential problem of
- * concurrent access to these functions by more than one thread,
- * where two clients might interfere with each other.
+ * concurrent access to these functions by more than one thread, where two
+ * clients might interfere with each other.
* <p>
- * Note: We also try to get the tracepoint info here, if it's not
- * already filled-in.
+ * Note: We also try to get the tracepoint info here, if it's not already
+ * filled-in.
*
- * @param rank a long corresponding to the number of the frame to be
- * selected and read
+ * @param rank
+ * a long corresponding to the number of the frame to be selected
+ * and read
* @return A GdbTraceEvent object, or null in case of failure.
*/
public synchronized GdbTraceEvent selectAndReadFrame(final long rank) {
// lazy init of tracepoints info
- if(fTpInfo.isEmpty()) {
+ if (fTpInfo.isEmpty()) {
getTracepointInfo();
}
if (selectDataFrame(rank, false)) {
return null;
}
-
/**
* This class implements a best-effort look-up of the detailed tracepoint
* information (source code filename, line number, etc...).
}
/**
- * This method uses the DSF-GDB interface to select a given frame number
- * in the current GDB tracepoint session.
+ * This method uses the DSF-GDB interface to select a given frame number in
+ * the current GDB tracepoint session.
*
- * @param rank the rank of the tracepoint frame to select.
- * @param update true if visualization should be updated
+ * @param rank
+ * the rank of the tracepoint frame to select.
+ * @param update
+ * true if visualization should be updated
* @return boolean true if select worked.
*/
public boolean selectDataFrame(final long rank, final boolean update) {
// get corresponding TP data
String tmfEventRef;
- MIBreakpointDMData bp = fTpInfo.get(Integer.valueOf(data.getTracepointNumber()));
+ MIBreakpointDMData bp = fTpInfo.get(Integer.valueOf(data.getTracepointNumber()));
if (bp != null) {
tmfEventRef = bp.getFileName() + ":" + bp.getLineNumber() + " :: " + bp.getFunctionName(); //$NON-NLS-1$ //$NON-NLS-2$
- }
- else {
+ } else {
tmfEventRef = tracedExecutable;
}
Integer.parseInt(data.getRecordId()));
GdbTraceEvent ev = new GdbTraceEvent(fGdbTrace,
- new TmfTimestamp(Integer.parseInt(data.getRecordId())),
+ TmfTimestamp.fromSeconds(Integer.parseInt(data.getRecordId())),
"Tracepoint: " + data.getTracepointNumber() + ", Frame: " + data.getRecordId(), //$NON-NLS-1$ //$NON-NLS-2$
tmfEventType,
evContent,
* This is a helper method for getTraceFrameData, to create for it a
* "best effort" GdbTraceEvent when a problem occurs during the reading.
*
- * @param rank long containing the number of the frame where the problem occurred
- * @param message String containing a brief explanation of problem.
+ * @param rank
+ * long containing the number of the frame where the problem
+ * occurred
+ * @param message
+ * String containing a brief explanation of problem.
* @return a GdbTraceEvent object, filled as best as possible
*/
private GdbTraceEvent createExceptionEvent(final long rank, final String message) {
// get corresponding TP data
String tmfEventRef;
String tmfEventSrc;
- MIBreakpointDMData bp = fTpInfo.get(rank);
+ MIBreakpointDMData bp = fTpInfo.get(rank);
if (bp != null) {
tmfEventRef = bp.getFileName() + ":" + bp.getLineNumber() + " :: " + bp.getFunctionName(); //$NON-NLS-1$ //$NON-NLS-2$
tmfEventSrc = bp.getFileName() + " :: " + bp.getFunctionName() + ", line: " + bp.getLineNumber(); //$NON-NLS-1$ //$NON-NLS-2$
- }
- else {
+ } else {
tmfEventRef = tracedExecutable;
tmfEventSrc = "Tracepoint: n/a"; //$NON-NLS-1$
}
GdbTraceEventContent evContent = new GdbTraceEventContent("ERROR: " + message, 0, 0); //$NON-NLS-1$
GdbTraceEvent ev = new GdbTraceEvent(fGdbTrace,
- new TmfTimestamp(rank),
+ TmfTimestamp.fromSeconds(rank),
tmfEventSrc,
tmfEventType,
evContent,
import org.eclipse.tracecompass.internal.gdbtrace.core.event.GdbTraceEventContent;
import org.eclipse.tracecompass.internal.gdbtrace.core.trace.GdbEventAspects;
import org.eclipse.tracecompass.internal.gdbtrace.core.trace.GdbTrace;
-import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
+import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
import org.eclipse.tracecompass.tmf.core.signal.TmfTraceUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment;
import static org.junit.Assert.assertNotNull;
-import org.eclipse.tracecompass.internal.lttng2.common.core.Activator;
import org.junit.Test;
/**
package org.eclipse.tracecompass.lttng2.control.core.tests.model.impl;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.util.LinkedList;
import java.util.List;
package org.eclipse.tracecompass.lttng2.control.core.tests.model.impl;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.util.LinkedList;
import java.util.List;
package org.eclipse.tracecompass.lttng2.control.core.tests.model.impl;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.util.LinkedList;
import java.util.List;
package org.eclipse.tracecompass.lttng2.control.core.tests.model.impl;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.IFieldInfo;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.FieldInfo;
package org.eclipse.tracecompass.lttng2.control.core.tests.model.impl;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.IProbeEventInfo;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceEnablement;
package org.eclipse.tracecompass.lttng2.control.core.tests.model.impl;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.util.LinkedList;
import java.util.List;
package org.eclipse.tracecompass.lttng2.control.core.tests.model.impl;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.impl.LttngRelaydConnectorFactory;
import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator;
import org.eclipse.tracecompass.tmf.core.signal.TmfTraceRangeUpdatedSignal;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
/**
if (indexReply.getStatus() == NextIndexReturnCode.VIEWER_INDEX_OK) {
long nanoTimeStamp = fCtfTmfTrace.timestampCyclesToNanos(indexReply.getTimestampEnd());
if (nanoTimeStamp > fTimestampEnd) {
- TmfNanoTimestamp endTime = new TmfNanoTimestamp(nanoTimeStamp);
+ ITmfTimestamp endTime = TmfTimestamp.fromNanos(nanoTimeStamp);
TmfTimeRange range = new TmfTimeRange(fCtfTmfTrace.getStartTime(), endTime);
long currentTime = System.nanoTime();
} else if (indexReply.getStatus() == NextIndexReturnCode.VIEWER_INDEX_HUP) {
// The trace is now complete because the trace session was destroyed
fCtfTmfTrace.setComplete(true);
- TmfTraceRangeUpdatedSignal signal = new TmfTraceRangeUpdatedSignal(LttngRelaydConsumer.this, fCtfTmfTrace, new TmfTimeRange(fCtfTmfTrace.getStartTime(), new TmfNanoTimestamp(fTimestampEnd)));
+ TmfTraceRangeUpdatedSignal signal = new TmfTraceRangeUpdatedSignal(LttngRelaydConsumer.this, fCtfTmfTrace, new TmfTimeRange(fCtfTmfTrace.getStartTime(), TmfTimestamp.fromNanos(fTimestampEnd)));
fCtfTmfTrace.broadcastAsync(signal);
return Status.OK_STATUS;
}
package org.eclipse.tracecompass.lttng2.kernel.core.tests;
-import junit.framework.TestCase;
-
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import junit.framework.TestCase;
+
/**
* <b><u>ActivatorTest</u></b>
* <p>
private static final long LTTNG_CONSUMER_BIRTHTIME = 1361214078963717040L;
private static final String LTTNG_CONSUMER_TID = "4034";
- private static final @NonNull TmfTimestamp TRACE_START_TIME = new TmfTimestamp(1361214078963711320L, ITmfTimestamp.NANOSECOND_SCALE);
+ private static final @NonNull ITmfTimestamp TRACE_START_TIME = TmfTimestamp.create(1361214078963711320L, ITmfTimestamp.NANOSECOND_SCALE);
// ------------------------------------------------------------------------
// Attributes
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
import org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView;
private static final String SELECT_PREVIOUS_EVENT = "Select Previous Event";
private static final String SELECT_NEXT_EVENT = "Select Next Event";
private static final Keyboard KEYBOARD = KeyboardFactory.getSWTKeyboard();
- private static final @NonNull ITmfTimestamp START_TIME = new TmfNanoTimestamp(1368000272650993664L);
- private static final @NonNull ITmfTimestamp TID1_TIME1 = new TmfNanoTimestamp(1368000272651208412L);
- private static final @NonNull ITmfTimestamp TID1_TIME2 = new TmfNanoTimestamp(1368000272656147616L);
- private static final @NonNull ITmfTimestamp TID1_TIME3 = new TmfNanoTimestamp(1368000272656362364L);
- private static final @NonNull ITmfTimestamp TID1_TIME4 = new TmfNanoTimestamp(1368000272663234300L);
- private static final @NonNull ITmfTimestamp TID1_TIME5 = new TmfNanoTimestamp(1368000272663449048L);
- private static final @NonNull ITmfTimestamp TID1_TIME6 = new TmfNanoTimestamp(1368000272665596528L);
- private static final @NonNull ITmfTimestamp TID2_TIME1 = new TmfNanoTimestamp(1368000272651852656L);
- private static final @NonNull ITmfTimestamp TID2_TIME2 = new TmfNanoTimestamp(1368000272652067404L);
- private static final @NonNull ITmfTimestamp TID2_TIME3 = new TmfNanoTimestamp(1368000272652282152L);
- private static final @NonNull ITmfTimestamp TID2_TIME4 = new TmfNanoTimestamp(1368000272652496900L);
- private static final @NonNull ITmfTimestamp TID5_TIME1 = new TmfNanoTimestamp(1368000272652496900L);
+ private static final @NonNull ITmfTimestamp START_TIME = TmfTimestamp.fromNanos(1368000272650993664L);
+ private static final @NonNull ITmfTimestamp TID1_TIME1 = TmfTimestamp.fromNanos(1368000272651208412L);
+ private static final @NonNull ITmfTimestamp TID1_TIME2 = TmfTimestamp.fromNanos(1368000272656147616L);
+ private static final @NonNull ITmfTimestamp TID1_TIME3 = TmfTimestamp.fromNanos(1368000272656362364L);
+ private static final @NonNull ITmfTimestamp TID1_TIME4 = TmfTimestamp.fromNanos(1368000272663234300L);
+ private static final @NonNull ITmfTimestamp TID1_TIME5 = TmfTimestamp.fromNanos(1368000272663449048L);
+ private static final @NonNull ITmfTimestamp TID1_TIME6 = TmfTimestamp.fromNanos(1368000272665596528L);
+ private static final @NonNull ITmfTimestamp TID2_TIME1 = TmfTimestamp.fromNanos(1368000272651852656L);
+ private static final @NonNull ITmfTimestamp TID2_TIME2 = TmfTimestamp.fromNanos(1368000272652067404L);
+ private static final @NonNull ITmfTimestamp TID2_TIME3 = TmfTimestamp.fromNanos(1368000272652282152L);
+ private static final @NonNull ITmfTimestamp TID2_TIME4 = TmfTimestamp.fromNanos(1368000272652496900L);
+ private static final @NonNull ITmfTimestamp TID5_TIME1 = TmfTimestamp.fromNanos(1368000272652496900L);
private SWTBotView fViewBot;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
import org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl;
private static final String LOST_EVENTS = "Lost Events";
private static final String OK = "OK";
private static final Keyboard KEYBOARD = KeyboardFactory.getSWTKeyboard();
- private static final @NonNull ITmfTimestamp START_TIME = new TmfNanoTimestamp(1368000272650993664L);
- private static final @NonNull ITmfTimestamp LOST_EVENT_TIME1 = new TmfNanoTimestamp(1368000272681793477L);
- private static final @NonNull ITmfTimestamp LOST_EVENT_END1 = new TmfNanoTimestamp(1368000272681793477L + 7425331L);
- private static final @NonNull ITmfTimestamp LOST_EVENT_TIME2 = new TmfNanoTimestamp(1368000272820875850L);
- private static final @NonNull ITmfTimestamp LOST_EVENT_END2 = new TmfNanoTimestamp(1368000272820875850L + 6640670L);
- private static final @NonNull ITmfTimestamp LOST_EVENT_TIME3 = new TmfNanoTimestamp(1368000272882715015L);
- private static final @NonNull ITmfTimestamp LOST_EVENT_END3 = new TmfNanoTimestamp(1368000272882715015L + 11373385L);
- private static final @NonNull ITmfTimestamp CPU0_TIME1 = new TmfNanoTimestamp(1368000272651208412L);
- private static final @NonNull ITmfTimestamp CPU0_TIME2 = new TmfNanoTimestamp(1368000272651852656L);
- private static final @NonNull ITmfTimestamp CPU0_TIME3 = new TmfNanoTimestamp(1368000272652067404L);
- private static final @NonNull ITmfTimestamp CPU0_TIME4 = new TmfNanoTimestamp(1368000272652282152L);
- private static final @NonNull ITmfTimestamp CPU0_TIME5 = new TmfNanoTimestamp(1368000272653141144L);
+ private static final @NonNull ITmfTimestamp START_TIME = TmfTimestamp.fromNanos(1368000272650993664L);
+ private static final @NonNull ITmfTimestamp LOST_EVENT_TIME1 = TmfTimestamp.fromNanos(1368000272681793477L);
+ private static final @NonNull ITmfTimestamp LOST_EVENT_END1 = TmfTimestamp.fromNanos(1368000272681793477L + 7425331L);
+ private static final @NonNull ITmfTimestamp LOST_EVENT_TIME2 = TmfTimestamp.fromNanos(1368000272820875850L);
+ private static final @NonNull ITmfTimestamp LOST_EVENT_END2 = TmfTimestamp.fromNanos(1368000272820875850L + 6640670L);
+ private static final @NonNull ITmfTimestamp LOST_EVENT_TIME3 = TmfTimestamp.fromNanos(1368000272882715015L);
+ private static final @NonNull ITmfTimestamp LOST_EVENT_END3 = TmfTimestamp.fromNanos(1368000272882715015L + 11373385L);
+ private static final @NonNull ITmfTimestamp CPU0_TIME1 = TmfTimestamp.fromNanos(1368000272651208412L);
+ private static final @NonNull ITmfTimestamp CPU0_TIME2 = TmfTimestamp.fromNanos(1368000272651852656L);
+ private static final @NonNull ITmfTimestamp CPU0_TIME3 = TmfTimestamp.fromNanos(1368000272652067404L);
+ private static final @NonNull ITmfTimestamp CPU0_TIME4 = TmfTimestamp.fromNanos(1368000272652282152L);
+ private static final @NonNull ITmfTimestamp CPU0_TIME5 = TmfTimestamp.fromNanos(1368000272653141144L);
private static final int TOP_MARGIN = 1;
private static final Point TOGGLE_SIZE = new Point(7, 8);
private static final Point HIDE_SIZE = new Point(16, 16);
package org.eclipse.tracecompass.lttng2.ust.core.tests;
-import junit.framework.TestCase;
-
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import junit.framework.TestCase;
+
/**
* <b><u>ActivatorTest</u></b>
* <p>
import org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.UstDebugInfoSourceAspect;
import org.eclipse.tracecompass.tmf.core.event.lookup.ITmfCallsite;
import org.eclipse.tracecompass.tmf.core.event.lookup.ITmfSourceLookup;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
* @param eventDefinition
* The event definition
*/
- protected LttngUstEvent(CtfTmfTrace trace, long rank, TmfNanoTimestamp timestamp,
+ protected LttngUstEvent(CtfTmfTrace trace, long rank, ITmfTimestamp timestamp,
String channel, int cpu, IEventDeclaration declaration, IEventDefinition eventDefinition) {
super(trace, rank, timestamp, channel, cpu, declaration, eventDefinition);
}
import org.eclipse.tracecompass.ctf.core.CTFStrings;
import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEventFactory;
/* Prepare what to pass to CtfTmfEvent's constructor */
final IEventDeclaration eventDecl = eventDef.getDeclaration();
final long ts = eventDef.getTimestamp();
- final TmfNanoTimestamp timestamp = trace.createTimestamp(trace.timestampCyclesToNanos(ts));
+ final ITmfTimestamp timestamp = trace.createTimestamp(trace.timestampCyclesToNanos(ts));
int sourceCPU = eventDef.getCPU();
import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils;
import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
private static void goToTime(long timestamp) {
SWTBotTable table = fBot.activeEditor().bot().table();
table.setFocus();
- TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(table.widget, new TmfNanoTimestamp(timestamp)));
+ TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(table.widget, TmfTimestamp.fromNanos(timestamp)));
fBot.waitUntil(ConditionHelpers.selectionInEventsTable(fBot, timestamp));
}
package org.eclipse.tracecompass.tmf.pcap.core.tests.event;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;
import java.io.IOException;
* @return The start time.
*/
public synchronized ITmfTimestamp getStartTime() {
- return new TmfTimestamp(fPacketStream.getStartTime(), ITmfTimestamp.NANOSECOND_SCALE);
+ return TmfTimestamp.fromNanos(fPacketStream.getStartTime());
}
/**
* @return The stop time.
*/
public synchronized ITmfTimestamp getStopTime() {
- return new TmfTimestamp(fPacketStream.getStopTime(), ITmfTimestamp.NANOSECOND_SCALE);
+ return TmfTimestamp.fromNanos(fPacketStream.getStopTime());
}
/**
switch (scale) {
case MICROSECOND:
long us = trace.getTimestampTransform().transform(timestamp * 1000) / 1000;
- tmfTimestamp = new TmfTimestamp(us, ITmfTimestamp.MICROSECOND_SCALE);
+ tmfTimestamp = TmfTimestamp.fromMicros(us);
break;
case NANOSECOND:
long ns = trace.getTimestampTransform().transform(timestamp);
- tmfTimestamp = new TmfTimestamp(ns, ITmfTimestamp.NANOSECOND_SCALE);
+ tmfTimestamp = TmfTimestamp.fromNanos(ns);
break;
default:
throw new IllegalArgumentException("The timestamp precision is not valid!"); //$NON-NLS-1$
/**
* Start event for pattern segment TEST_2
*/
- public static final @NonNull ITmfEvent TEST_2_START_EVENT = new TmfEvent(null, ITmfContext.UNKNOWN_RANK, new TmfTimestamp(1, ITmfTimestamp.NANOSECOND_SCALE), null, null);
+ public static final @NonNull ITmfEvent TEST_2_START_EVENT = new TmfEvent(null, ITmfContext.UNKNOWN_RANK, TmfTimestamp.fromNanos(1), null, null);
/**
* end event for pattern segment TEST_2
*/
- public static final @NonNull ITmfEvent TEST_2_END_EVENT = new TmfEvent(null, ITmfContext.UNKNOWN_RANK, new TmfTimestamp(10, ITmfTimestamp.NANOSECOND_SCALE), null, null);
+ public static final @NonNull ITmfEvent TEST_2_END_EVENT = new TmfEvent(null, ITmfContext.UNKNOWN_RANK, TmfTimestamp.fromNanos(10), null, null);
/**
* The pattern segment TEST_2
* @return The start timestamp
*/
public @NonNull ITmfTimestamp getTimestampStart() {
- return new TmfTimestamp(fStart, fScale);
+ return TmfTimestamp.create(fStart, fScale);
}
/**
* @return The end timestamp
*/
public @NonNull ITmfTimestamp getTimestampEnd() {
- return new TmfTimestamp(fEnd, fScale);
+ return TmfTimestamp.create(fEnd, fScale);
}
/**
import java.util.Set;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisRequirement.ValuePriorityLevel;
import org.eclipse.tracecompass.tmf.core.analysis.requirements.IAnalysisRequirementProvider;
+import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisRequirement.ValuePriorityLevel;
import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisRequirementHelper;
import org.eclipse.tracecompass.tmf.tests.stubs.analysis.AnalysisModuleTestHelper;
import org.eclipse.tracecompass.tmf.tests.stubs.analysis.AnalysisModuleTestHelper.moduleStubEnum;
package org.eclipse.tracecompass.tmf.core.tests.analysis.requirements;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisRequirement;
import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisRequirement.ValuePriorityLevel;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
import org.junit.Test;
/**
import org.eclipse.tracecompass.internal.tmf.core.component.TmfProviderManager;
import org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
-import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest;
import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest.ExecutionType;
+import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest;
import org.eclipse.tracecompass.tmf.core.signal.TmfEndSynchSignal;
import org.eclipse.tracecompass.tmf.core.signal.TmfStartSynchSignal;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.tests.stubs.component.TmfEventProviderStub;
*/
@Test
public void testGetSyntheticEvents_TimeRange() {
- TmfTimestamp start = new TmfTimestamp(1, (byte) -3);
- TmfTimestamp end = new TmfTimestamp(1000, (byte) -3);
+ ITmfTimestamp start = TmfTimestamp.create(1, (byte) -3);
+ ITmfTimestamp end = TmfTimestamp.create(1000, (byte) -3);
TmfTimeRange range = new TmfTimeRange(start, end);
try {
getSyntheticData(range, -1);
// public void testGetSyntheticEvents_WeirdTimeRange1() {
// TmfTimestamp start = TmfTimestamp.BigBang;
-// TmfTimestamp end = TmfTimestamp.Zero; // new TmfTimestamp(0, (byte) -3,
+// TmfTimestamp end = TmfTimestamp.Zero; // TmfTimestamp.create(0, (byte) -3,
// // 0);
// TmfTimeRange range = new TmfTimeRange(start, end);
// try {
// }
// public void testGetSyntheticEvents_WeirdTimeRange2() {
-// TmfTimestamp start = TmfTimestamp.Zero; // new TmfTimestamp(0, (byte)
+// TmfTimestamp start = TmfTimestamp.Zero; // TmfTimestamp.create(0, (byte)
// // -3, 0);
// TmfTimestamp end = TmfTimestamp.BigCrunch;
// TmfTimeRange range = new TmfTimeRange(start, end);
import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestTrace;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
private final ITmfEventField[] fFields1 = new ITmfEventField[] { fField1a, fField1b };
private final @NonNull String fRawContent1 = fField1a.toString() + fField1b.toString();
private final ITmfEventField fContent1 = new TmfEventField(fRawContent1, null, fFields1);
- private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, 2);
+ private final ITmfTimestamp fTimestamp1 = TmfTimestamp.create(12345, 2);
private final @NonNull ITmfEvent fEvent1 = new TmfEvent(fTrace, 0, fTimestamp1, fType, fContent1);
private final Object fValue2a = "Another string";
private final ITmfEventField[] fFields2 = new ITmfEventField[] { fField2a, fField2b };
private final @NonNull String fRawContent2 = fField2a.toString() + fField2b.toString();
private final ITmfEventField fContent2 = new TmfEventField(fRawContent2, null, fFields2);
- private final TmfTimestamp fTimestamp2 = new TmfTimestamp(12350, 2);
+ private final ITmfTimestamp fTimestamp2 = TmfTimestamp.create(12350, 2);
private final @NonNull ITmfEvent fEvent2 = new TmfEvent(fTrace, 1, fTimestamp2, fType, fContent2);
// ------------------------------------------------------------------------
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
// Variables
// ------------------------------------------------------------------------
- private final ITmfTimestamp ts0 = new TmfNanoTimestamp();
+ private final ITmfTimestamp ts0 = new TmfNanoTimestamp(0);
private final ITmfTimestamp ts1 = new TmfNanoTimestamp(12345);
private final ITmfTimestamp ts2 = new TmfNanoTimestamp(-1234);
@Test
public void testCopyConstructor() {
- final ITmfTimestamp copy = new TmfNanoTimestamp(ts1);
+ final long copy = ts1.toNanos();
- assertEquals("getValue", ts1.getValue(), copy.getValue());
- assertEquals("getscale", ts1.getScale(), copy.getScale());
+ assertEquals("getValue", ts1.getValue(), copy);
+ assertEquals("getscale", ts1.getScale(), -9);
- assertEquals("getValue", 12345, copy.getValue());
- assertEquals("getscale", -9, copy.getScale());
- }
-
- @Test
- public void testCopyBadTimestamp() {
- try {
- new TmfNanoTimestamp(null);
- fail("TmfNanoTimestamp: null argument");
- } catch (final NullPointerException e) {
- }
+ assertEquals("getValue", 12345, copy);
}
// ------------------------------------------------------------------------
@Test
public void testEqualsSymmetry() {
- final ITmfTimestamp ts0copy = new TmfNanoTimestamp(ts0);
+ final ITmfTimestamp ts0copy = TmfTimestamp.fromNanos(ts0.toNanos());
assertTrue("equals", ts0.equals(ts0copy));
assertTrue("equals", ts0copy.equals(ts0));
- final ITmfTimestamp ts1copy = new TmfNanoTimestamp(ts1);
+ final ITmfTimestamp ts1copy = TmfTimestamp.fromNanos(ts1.toNanos());
assertTrue("equals", ts1.equals(ts1copy));
assertTrue("equals", ts1copy.equals(ts1));
}
@Test
public void testEqualsTransivity() {
- final ITmfTimestamp ts0copy1 = new TmfNanoTimestamp(ts0);
- final ITmfTimestamp ts0copy2 = new TmfNanoTimestamp(ts0copy1);
+ final ITmfTimestamp ts0copy1 = TmfTimestamp.fromNanos(ts0.toNanos());
+ final ITmfTimestamp ts0copy2 = TmfTimestamp.fromNanos(ts0copy1.toNanos());
assertTrue("equals", ts0.equals(ts0copy1));
assertTrue("equals", ts0copy1.equals(ts0copy2));
assertTrue("equals", ts0.equals(ts0copy2));
- final ITmfTimestamp ts1copy1 = new TmfNanoTimestamp(ts1);
- final ITmfTimestamp ts1copy2 = new TmfNanoTimestamp(ts1copy1);
+ final ITmfTimestamp ts1copy1 = TmfTimestamp.fromNanos(ts1.toNanos());
+ final ITmfTimestamp ts1copy2 = TmfTimestamp.fromNanos(ts1copy1.toNanos());
assertTrue("equals", ts1.equals(ts1copy1));
assertTrue("equals", ts1copy1.equals(ts1copy2));
assertTrue("equals", ts1.equals(ts1copy2));
@Test
public void testHashCode() {
- final ITmfTimestamp ts0copy = new TmfTimestamp(ts0);
- final ITmfTimestamp ts1copy = new TmfTimestamp(ts1);
- final ITmfTimestamp ts2copy = new TmfTimestamp(ts2);
+ final ITmfTimestamp ts0copy = TmfTimestamp.create(ts0.getValue(), ts0.getScale());
+ final ITmfTimestamp ts1copy = TmfTimestamp.create(ts1.getValue(), ts1.getScale());
+ final ITmfTimestamp ts2copy = TmfTimestamp.create(ts2.getValue(), ts2.getScale());
- assertTrue("hashCode", ts0.hashCode() == ts0copy.hashCode());
- assertTrue("hashCode", ts1.hashCode() == ts1copy.hashCode());
- assertTrue("hashCode", ts2.hashCode() == ts2copy.hashCode());
+ assertEquals("hashCode", ts0.hashCode(), ts0copy.hashCode());
+ assertEquals("hashCode", ts1.hashCode(), ts1copy.hashCode());
+ assertEquals("hashCode", ts2.hashCode(), ts2copy.hashCode());
assertTrue("hashCode", ts0.hashCode() != ts1.hashCode());
}
@Test
public void testBasicCompareTo() {
- final ITmfTimestamp tstamp1 = new TmfNanoTimestamp(900);
- final ITmfTimestamp tstamp2 = new TmfNanoTimestamp(1000);
- final ITmfTimestamp tstamp3 = new TmfNanoTimestamp(1100);
+ final ITmfTimestamp tstamp1 = TmfTimestamp.fromNanos(900);
+ final ITmfTimestamp tstamp2 = TmfTimestamp.fromNanos(1000);
+ final ITmfTimestamp tstamp3 = TmfTimestamp.fromNanos(1100);
assertTrue(tstamp1.compareTo(tstamp1) == 0);
@Test
public void testCompareTo() {
- final ITmfTimestamp ts0a = new TmfTimestamp(0, 2);
- final ITmfTimestamp ts1a = new TmfTimestamp(123450, -10);
- final ITmfTimestamp ts2a = new TmfTimestamp(-12340, -10);
+ final ITmfTimestamp ts0a = TmfTimestamp.create(0, 2);
+ final ITmfTimestamp ts1a = TmfTimestamp.create(123450, -10);
+ final ITmfTimestamp ts2a = TmfTimestamp.create(-12340, -10);
assertTrue(ts1.compareTo(ts1) == 0);
@Test
public void testDelta() {
// Delta for same scale and precision (delta > 0)
- TmfTimestamp tstamp0 = new TmfNanoTimestamp(10);
- TmfTimestamp tstamp1 = new TmfNanoTimestamp(5);
- TmfTimestamp expectd = new TmfNanoTimestamp(5);
+ ITmfTimestamp tstamp0 = TmfTimestamp.fromNanos(10);
+ ITmfTimestamp tstamp1 = TmfTimestamp.fromNanos(5);
+ ITmfTimestamp expectd = TmfTimestamp.fromNanos(5);
ITmfTimestamp delta = tstamp0.getDelta(tstamp1);
assertEquals("getDelta", 0, delta.compareTo(expectd));
// Delta for same scale and precision (delta < 0)
- tstamp0 = new TmfTimestamp(5);
- tstamp1 = new TmfTimestamp(10);
- expectd = new TmfTimestamp(-5);
+ tstamp0 = TmfTimestamp.fromSeconds(5);
+ tstamp1 = TmfTimestamp.fromSeconds(10);
+ expectd = TmfTimestamp.fromSeconds(-5);
delta = tstamp0.getDelta(tstamp1);
assertEquals("getDelta", 0, delta.compareTo(expectd));
@Test
public void testDelta2() {
// Delta for different scale and same precision (delta > 0)
- final TmfTimestamp tstamp0 = new TmfNanoTimestamp(10);
- final TmfTimestamp tstamp1 = new TmfTimestamp(1, -8);
- final TmfTimestamp expectd = new TmfTimestamp(0, 0);
+ final ITmfTimestamp tstamp0 = TmfTimestamp.fromNanos(10);
+ final ITmfTimestamp tstamp1 = TmfTimestamp.create(1, -8);
+ final ITmfTimestamp expectd = TmfTimestamp.create(0, 0);
final ITmfTimestamp delta = tstamp0.getDelta(tstamp1);
assertEquals("getDelta", 0, delta.compareTo(expectd));
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012, 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ * Alexandre Montplaisir - Port to JUnit4
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.tmf.core.tests.event;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfSecondTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
+import org.junit.Test;
+
+/**
+ * Test suite for the {@link TmfSecondTimestamp} class.
+ */
+@SuppressWarnings("javadoc")
+public class TmfSecondTimestampTest {
+
+ // ------------------------------------------------------------------------
+ // Variables
+ // ------------------------------------------------------------------------
+
+ private final ITmfTimestamp ts0 = new TmfSecondTimestamp(0);
+ private final ITmfTimestamp ts1 = new TmfSecondTimestamp(12345);
+ private final ITmfTimestamp ts2 = new TmfSecondTimestamp(-1234);
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testDefaultConstructor() {
+ assertEquals("getValue", 0, ts0.getValue());
+ assertEquals("getscale", 0, ts0.getScale());
+ }
+
+ @Test
+ public void testFullConstructor() {
+ assertEquals("getValue", 12345, ts1.getValue());
+ assertEquals("getscale", 0, ts1.getScale());
+ }
+
+ // ------------------------------------------------------------------------
+ // equals
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testEqualsReflexivity() {
+ assertEquals("equals", ts0, ts0);
+ assertEquals("equals", ts1, ts1);
+ assertEquals("equals", ts2, ts2);
+
+ assertFalse("different", ts0.equals(ts1));
+ assertFalse("different", ts0.equals(ts2));
+
+ assertFalse("different", ts1.equals(ts0));
+ assertFalse("different", ts1.equals(ts2));
+
+ assertFalse("different", ts2.equals(ts0));
+ assertFalse("different", ts2.equals(ts1));
+ }
+
+ @Test
+ public void testEqualsNull() {
+ assertTrue("different", !ts0.equals(null));
+ assertTrue("different", !ts1.equals(null));
+ assertTrue("different", !ts2.equals(null));
+ }
+
+ @Test
+ public void testEqualsNonTimestamp() {
+ assertFalse("equals", ts0.equals(ts0.toString()));
+ }
+
+ // ------------------------------------------------------------------------
+ // toString
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testToString() {
+ DateFormat df = new SimpleDateFormat("HH:mm:ss.SSS");
+ Date d0 = new Date(ts0.getValue() * 1000);
+ Date d1 = new Date(ts1.getValue() * 1000);
+ Date d2 = new Date(ts2.getValue() * 1000);
+ assertEquals("toString", df.format(d0) + " 000 000", ts0.toString());
+ assertEquals("toString", df.format(d1) + " 000 000", ts1.toString());
+ assertEquals("toString", df.format(d2) + " 000 000", ts2.toString());
+ }
+
+ // ------------------------------------------------------------------------
+ // hashCode
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testHashCode() {
+ final ITmfTimestamp ts0copy = TmfTimestamp.create(ts0.getValue(), ts0.getScale());
+ final ITmfTimestamp ts1copy = TmfTimestamp.create(ts1.getValue(), ts1.getScale());
+ final ITmfTimestamp ts2copy = TmfTimestamp.create(ts2.getValue(), ts2.getScale());
+
+ assertEquals("hashCode", ts0.hashCode(), ts0copy.hashCode());
+ assertEquals("hashCode", ts1.hashCode(), ts1copy.hashCode());
+ assertEquals("hashCode", ts2.hashCode(), ts2copy.hashCode());
+ }
+
+ // ------------------------------------------------------------------------
+ // normalize
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testNormalizeScale0() {
+ ITmfTimestamp ts = ts0.normalize(0, 0);
+ assertEquals("getValue", 0, ts.getValue());
+ assertEquals("getscale", 0, ts.getScale());
+
+ ts = ts0.normalize(12345, 0);
+ assertEquals("getValue", 12345, ts.getValue());
+ assertEquals("getscale", 0, ts.getScale());
+
+ ts = ts0.normalize(10, 0);
+ assertEquals("getValue", 10, ts.getValue());
+ assertEquals("getscale", 0, ts.getScale());
+
+ ts = ts0.normalize(-10, 0);
+ assertEquals("getValue", -10, ts.getValue());
+ assertEquals("getscale", 0, ts.getScale());
+ }
+
+ @Test
+ public void testNormalizeScaleNot0() {
+ ITmfTimestamp ts = ts0.normalize(0, 1);
+ assertEquals("getValue", 0, ts.getValue());
+ assertEquals("getscale", 1, ts.getScale());
+
+ ts = ts0.normalize(12345, 1);
+ assertEquals("getValue", 12345, ts.getValue());
+ assertEquals("getscale", 1, ts.getScale());
+
+ ts = ts0.normalize(10, 1);
+ assertEquals("getValue", 10, ts.getValue());
+ assertEquals("getscale", 1, ts.getScale());
+
+ ts = ts0.normalize(-10, 1);
+ assertEquals("getValue", -10, ts.getValue());
+ assertEquals("getscale", 1, ts.getScale());
+ }
+
+ // ------------------------------------------------------------------------
+ // compareTo
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testBasicCompareTo() {
+ final ITmfTimestamp tstamp1 = TmfTimestamp.fromSeconds(900);
+ final ITmfTimestamp tstamp2 = TmfTimestamp.fromSeconds(1000);
+ final ITmfTimestamp tstamp3 = TmfTimestamp.fromSeconds(1100);
+
+ assertTrue(tstamp1.compareTo(tstamp1) == 0);
+
+ assertTrue("CompareTo", tstamp1.compareTo(tstamp2) < 0);
+ assertTrue("CompareTo", tstamp1.compareTo(tstamp3) < 0);
+
+ assertTrue("CompareTo", tstamp2.compareTo(tstamp1) > 0);
+ assertTrue("CompareTo", tstamp2.compareTo(tstamp3) < 0);
+
+ assertTrue("CompareTo", tstamp3.compareTo(tstamp1) > 0);
+ assertTrue("CompareTo", tstamp3.compareTo(tstamp2) > 0);
+ }
+
+ @Test
+ public void testCompareTo() {
+ final ITmfTimestamp ts0a = TmfTimestamp.create(0, 2);
+ final ITmfTimestamp ts1a = TmfTimestamp.create(123450, -1);
+ final ITmfTimestamp ts2a = TmfTimestamp.create(-12340, -1);
+
+ assertTrue(ts1.compareTo(ts1) == 0);
+
+ assertTrue("CompareTo", ts0.compareTo(ts0a) == 0);
+ assertTrue("CompareTo", ts1.compareTo(ts1a) == 0);
+ assertTrue("CompareTo", ts2.compareTo(ts2a) == 0);
+ }
+
+ // ------------------------------------------------------------------------
+ // getDelta
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testDelta() {
+ // Delta for same scale and precision (delta > 0)
+ ITmfTimestamp tstamp0 = TmfTimestamp.fromSeconds(10);
+ ITmfTimestamp tstamp1 = TmfTimestamp.fromSeconds(5);
+ ITmfTimestamp expectd = TmfTimestamp.fromSeconds(5);
+
+ ITmfTimestamp delta = tstamp0.getDelta(tstamp1);
+ assertEquals("getDelta", 0, delta.compareTo(expectd));
+
+ // Delta for same scale and precision (delta < 0)
+ tstamp0 = TmfTimestamp.fromSeconds(5);
+ tstamp1 = TmfTimestamp.fromSeconds(10);
+ expectd = TmfTimestamp.fromSeconds(-5);
+
+ delta = tstamp0.getDelta(tstamp1);
+ assertEquals("getDelta", 0, delta.compareTo(expectd));
+ }
+
+ @Test
+ public void testDelta2() {
+ // Delta for different scale and same precision (delta > 0)
+ final ITmfTimestamp tstamp0 = TmfTimestamp.fromSeconds(10);
+ final ITmfTimestamp tstamp1 = TmfTimestamp.create(1, 1);
+ final ITmfTimestamp expectd = TmfTimestamp.create(0, 0);
+
+ final ITmfTimestamp delta = tstamp0.getDelta(tstamp1);
+ assertEquals("getDelta", 0, delta.compareTo(expectd));
+ }
+
+}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2012, 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.tracecompass.tmf.core.tests.event;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfSimpleTimestamp;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfSimpleTimestampTest class.
- */
-@SuppressWarnings("javadoc")
-public class TmfSimpleTimestampTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private final ITmfTimestamp ts0 = new TmfSimpleTimestamp();
- private final ITmfTimestamp ts1 = new TmfSimpleTimestamp(12345);
- private final ITmfTimestamp ts2 = new TmfSimpleTimestamp(-1234);
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- @Test
- public void testDefaultConstructor() {
- assertEquals("getValue", 0, ts0.getValue());
- assertEquals("getscale", 0, ts0.getScale());
- }
-
- @Test
- public void testFullConstructor() {
- assertEquals("getValue", 12345, ts1.getValue());
- assertEquals("getscale", 0, ts1.getScale());
- }
-
- @Test
- public void testCopyConstructor() {
- final ITmfTimestamp copy = new TmfSimpleTimestamp(ts1);
-
- assertEquals("getValue", ts1.getValue(), copy.getValue());
- assertEquals("getscale", ts1.getScale(), copy.getScale());
-
- assertEquals("getValue", 12345, copy.getValue());
- assertEquals("getscale", 0, copy.getScale());
- }
-
- @Test
- public void testCopyBadTimestamp() {
- try {
- new TmfSimpleTimestamp(null);
- fail("TmfSimpleTimestamp: null argument");
- } catch (final NullPointerException e) {
- }
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- @Test
- public void testEqualsReflexivity() {
- assertTrue("equals", ts0.equals(ts0));
- assertTrue("equals", ts1.equals(ts1));
- assertTrue("equals", ts2.equals(ts2));
-
- assertTrue("equals", !ts0.equals(ts1));
- assertTrue("equals", !ts0.equals(ts2));
-
- assertTrue("equals", !ts1.equals(ts0));
- assertTrue("equals", !ts1.equals(ts2));
-
- assertTrue("equals", !ts2.equals(ts0));
- assertTrue("equals", !ts2.equals(ts1));
- }
-
- @Test
- public void testEqualsSymmetry() {
- final ITmfTimestamp ts0copy = new TmfSimpleTimestamp(ts0);
- assertTrue("equals", ts0.equals(ts0copy));
- assertTrue("equals", ts0copy.equals(ts0));
-
- final ITmfTimestamp ts1copy = new TmfSimpleTimestamp(ts1);
- assertTrue("equals", ts1.equals(ts1copy));
- assertTrue("equals", ts1copy.equals(ts1));
- }
-
- @Test
- public void testEqualsTransivity() {
- final ITmfTimestamp ts0copy1 = new TmfSimpleTimestamp(ts0);
- final ITmfTimestamp ts0copy2 = new TmfSimpleTimestamp(ts0copy1);
- assertTrue("equals", ts0.equals(ts0copy1));
- assertTrue("equals", ts0copy1.equals(ts0copy2));
- assertTrue("equals", ts0.equals(ts0copy2));
-
- final ITmfTimestamp ts1copy1 = new TmfSimpleTimestamp(ts1);
- final ITmfTimestamp ts1copy2 = new TmfSimpleTimestamp(ts1copy1);
- assertTrue("equals", ts1.equals(ts1copy1));
- assertTrue("equals", ts1copy1.equals(ts1copy2));
- assertTrue("equals", ts1.equals(ts1copy2));
- }
-
- @Test
- public void testEqualsNull() {
- assertTrue("equals", !ts0.equals(null));
- assertTrue("equals", !ts1.equals(null));
- assertTrue("equals", !ts2.equals(null));
- }
-
- @Test
- public void testEqualsNonTimestamp() {
- assertFalse("equals", ts0.equals(ts0.toString()));
- }
-
- // ------------------------------------------------------------------------
- // toString
- // ------------------------------------------------------------------------
-
- @Test
- public void testToString() {
- DateFormat df = new SimpleDateFormat("HH:mm:ss.SSS");
- Date d0 = new Date(ts0.getValue()*1000);
- Date d1 = new Date(ts1.getValue()*1000);
- Date d2 = new Date(ts2.getValue()*1000);
- assertEquals("toString", df.format(d0) + " 000 000", ts0.toString());
- assertEquals("toString", df.format(d1) + " 000 000", ts1.toString());
- assertEquals("toString", df.format(d2) + " 000 000", ts2.toString());
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- @Test
- public void testHashCode() {
- final ITmfTimestamp ts0copy = new TmfTimestamp(ts0);
- final ITmfTimestamp ts1copy = new TmfTimestamp(ts1);
- final ITmfTimestamp ts2copy = new TmfTimestamp(ts2);
-
- assertTrue("hashCode", ts0.hashCode() == ts0copy.hashCode());
- assertTrue("hashCode", ts1.hashCode() == ts1copy.hashCode());
- assertTrue("hashCode", ts2.hashCode() == ts2copy.hashCode());
-
- assertTrue("hashCode", ts0.hashCode() != ts1.hashCode());
- }
-
- // ------------------------------------------------------------------------
- // normalize
- // ------------------------------------------------------------------------
-
- @Test
- public void testNormalizeScale0() {
- ITmfTimestamp ts = ts0.normalize(0, 0);
- assertEquals("getValue", 0, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
-
- ts = ts0.normalize(12345, 0);
- assertEquals("getValue", 12345, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
-
- ts = ts0.normalize(10, 0);
- assertEquals("getValue", 10, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
-
- ts = ts0.normalize(-10, 0);
- assertEquals("getValue", -10, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- }
-
- @Test
- public void testNormalizeScaleNot0() {
- ITmfTimestamp ts = ts0.normalize(0, 1);
- assertEquals("getValue", 0, ts.getValue());
- assertEquals("getscale", 1, ts.getScale());
-
- ts = ts0.normalize(12345, 1);
- assertEquals("getValue", 12345, ts.getValue());
- assertEquals("getscale", 1, ts.getScale());
-
- ts = ts0.normalize(10, 1);
- assertEquals("getValue", 10, ts.getValue());
- assertEquals("getscale", 1, ts.getScale());
-
- ts = ts0.normalize(-10, 1);
- assertEquals("getValue", -10, ts.getValue());
- assertEquals("getscale", 1, ts.getScale());
- }
-
- // ------------------------------------------------------------------------
- // compareTo
- // ------------------------------------------------------------------------
-
- @Test
- public void testBasicCompareTo() {
- final ITmfTimestamp tstamp1 = new TmfSimpleTimestamp(900);
- final ITmfTimestamp tstamp2 = new TmfSimpleTimestamp(1000);
- final ITmfTimestamp tstamp3 = new TmfSimpleTimestamp(1100);
-
- assertTrue(tstamp1.compareTo(tstamp1) == 0);
-
- assertTrue("CompareTo", tstamp1.compareTo(tstamp2) < 0);
- assertTrue("CompareTo", tstamp1.compareTo(tstamp3) < 0);
-
- assertTrue("CompareTo", tstamp2.compareTo(tstamp1) > 0);
- assertTrue("CompareTo", tstamp2.compareTo(tstamp3) < 0);
-
- assertTrue("CompareTo", tstamp3.compareTo(tstamp1) > 0);
- assertTrue("CompareTo", tstamp3.compareTo(tstamp2) > 0);
- }
-
- @Test
- public void testCompareTo() {
- final ITmfTimestamp ts0a = new TmfTimestamp(0, 2);
- final ITmfTimestamp ts1a = new TmfTimestamp(123450, -1);
- final ITmfTimestamp ts2a = new TmfTimestamp(-12340, -1);
-
- assertTrue(ts1.compareTo(ts1) == 0);
-
- assertTrue("CompareTo", ts0.compareTo(ts0a) == 0);
- assertTrue("CompareTo", ts1.compareTo(ts1a) == 0);
- assertTrue("CompareTo", ts2.compareTo(ts2a) == 0);
- }
-
- // ------------------------------------------------------------------------
- // getDelta
- // ------------------------------------------------------------------------
-
- @Test
- public void testDelta() {
- // Delta for same scale and precision (delta > 0)
- TmfTimestamp tstamp0 = new TmfSimpleTimestamp(10);
- TmfTimestamp tstamp1 = new TmfSimpleTimestamp(5);
- TmfTimestamp expectd = new TmfSimpleTimestamp(5);
-
- ITmfTimestamp delta = tstamp0.getDelta(tstamp1);
- assertEquals("getDelta", 0, delta.compareTo(expectd));
-
- // Delta for same scale and precision (delta < 0)
- tstamp0 = new TmfTimestamp(5);
- tstamp1 = new TmfTimestamp(10);
- expectd = new TmfTimestamp(-5);
-
- delta = tstamp0.getDelta(tstamp1);
- assertEquals("getDelta", 0, delta.compareTo(expectd));
- }
-
- @Test
- public void testDelta2() {
- // Delta for different scale and same precision (delta > 0)
- final TmfTimestamp tstamp0 = new TmfSimpleTimestamp(10);
- final TmfTimestamp tstamp1 = new TmfTimestamp(1, 1);
- final TmfTimestamp expectd = new TmfTimestamp(0, 0);
-
- final ITmfTimestamp delta = tstamp0.getDelta(tstamp1);
- assertEquals("getDelta", 0, delta.compareTo(expectd));
- }
-
-}
@Test
public void testConstructor() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
+ final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345);
+ final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350);
final TmfTimeRange range = new TmfTimeRange(ts1, ts2);
assertEquals("startTime", ts1, range.getStartTime());
@Test
public void testOpenRange1() {
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
+ final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350);
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, ts2);
assertEquals("startTime", TmfTimestamp.BIG_BANG, range.getStartTime());
@Test
public void testOpenRange2() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
+ final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345);
final TmfTimeRange range = new TmfTimeRange(ts1, TmfTimestamp.BIG_CRUNCH);
assertEquals("startTime", ts1, range.getStartTime());
@Test
public void testHashCode() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
+ final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345);
+ final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350);
final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2);
final TmfTimeRange range1b =new TmfTimeRange(ts1, ts2);
final TmfTimeRange range2 = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
@Test
public void testEqualsReflexivity() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
+ final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345);
+ final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350);
final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2);
final TmfTimeRange range2 = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
@Test
public void testEqualsSymmetry() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
+ final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345);
+ final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350);
final TmfTimeRange range1a = new TmfTimeRange(ts1, ts2);
final TmfTimeRange range1b = new TmfTimeRange(ts1, ts2);
@Test
public void testEqualsTransivity() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
+ final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345);
+ final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350);
final TmfTimeRange range1a = new TmfTimeRange(ts1, ts2);
final TmfTimeRange range1b = new TmfTimeRange(ts1, ts2);
final TmfTimeRange range1c = new TmfTimeRange(ts1, ts2);
@Test
public void testEqualsNull() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
+ final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345);
+ final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350);
final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2);
assertTrue("equals", !range1.equals(null));
@Test
public void testEqualsBadType() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
+ final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345);
+ final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350);
final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2);
assertTrue("equals", !range1.equals(ts1));
@Test
public void testEqualStartTime() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
- final ITmfTimestamp ts3 = new TmfTimestamp(12355);
+ final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345);
+ final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350);
+ final ITmfTimestamp ts3 = TmfTimestamp.fromSeconds(12355);
final TmfTimeRange range1 = new TmfTimeRange(ts1, ts3);
final TmfTimeRange range2 = new TmfTimeRange(ts2, ts3);
@Test
public void testEqualsEndTime() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
- final ITmfTimestamp ts3 = new TmfTimestamp(12355);
+ final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345);
+ final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350);
+ final ITmfTimestamp ts3 = TmfTimestamp.fromSeconds(12355);
final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2);
final TmfTimeRange range2 = new TmfTimeRange(ts1, ts3);
@Test
public void testToString() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
+ final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345);
+ final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350);
final TmfTimeRange range = new TmfTimeRange(ts1, ts2);
final String expected = "TmfTimeRange [fStartTime=" + ts1 + ", fEndTime=" + ts2 + "]";
@Test
public void testContainsTimestamp() {
- final ITmfTimestamp ts1 = new TmfTimestamp(12345);
- final ITmfTimestamp ts2 = new TmfTimestamp(12350);
+ final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345);
+ final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350);
final TmfTimeRange range = new TmfTimeRange(ts1, ts2);
- assertTrue("contains (lower bound)", range.contains(new TmfTimestamp(12345)));
- assertTrue("contains (higher bound)", range.contains(new TmfTimestamp(12350)));
- assertTrue("contains (within bounds)", range.contains(new TmfTimestamp(12346)));
+ assertTrue("contains (lower bound)", range.contains(TmfTimestamp.fromSeconds(12345)));
+ assertTrue("contains (higher bound)", range.contains(TmfTimestamp.fromSeconds(12350)));
+ assertTrue("contains (within bounds)", range.contains(TmfTimestamp.fromSeconds(12346)));
- assertFalse("contains (low value)", range.contains(new TmfTimestamp(12340)));
- assertFalse("contains (high value)", range.contains(new TmfTimestamp(12351)));
+ assertFalse("contains (low value)", range.contains(TmfTimestamp.fromSeconds(12340)));
+ assertFalse("contains (high value)", range.contains(TmfTimestamp.fromSeconds(12351)));
}
@Test
public void testContainsRange() {
- final ITmfTimestamp ts1 = new TmfTimestamp(10);
- final ITmfTimestamp ts2 = new TmfTimestamp(20);
- final ITmfTimestamp ts3 = new TmfTimestamp(30);
- final ITmfTimestamp ts4 = new TmfTimestamp(40);
- final ITmfTimestamp ts5 = new TmfTimestamp(50);
- final ITmfTimestamp ts6 = new TmfTimestamp(60);
- final ITmfTimestamp ts7 = new TmfTimestamp(70);
- final ITmfTimestamp ts8 = new TmfTimestamp(80);
+ final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(10);
+ final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(20);
+ final ITmfTimestamp ts3 = TmfTimestamp.fromSeconds(30);
+ final ITmfTimestamp ts4 = TmfTimestamp.fromSeconds(40);
+ final ITmfTimestamp ts5 = TmfTimestamp.fromSeconds(50);
+ final ITmfTimestamp ts6 = TmfTimestamp.fromSeconds(60);
+ final ITmfTimestamp ts7 = TmfTimestamp.fromSeconds(70);
+ final ITmfTimestamp ts8 = TmfTimestamp.fromSeconds(80);
// Reference range
final TmfTimeRange range0 = new TmfTimeRange(ts3, ts6);
@Test
public void testGetIntersection() {
- final ITmfTimestamp ts1a = new TmfTimestamp(1000);
- final ITmfTimestamp ts1b = new TmfTimestamp(2000);
+ final ITmfTimestamp ts1a = TmfTimestamp.fromSeconds(1000);
+ final ITmfTimestamp ts1b = TmfTimestamp.fromSeconds(2000);
final TmfTimeRange range1 = new TmfTimeRange(ts1a, ts1b);
- final ITmfTimestamp ts2a = new TmfTimestamp(2000);
- final ITmfTimestamp ts2b = new TmfTimestamp(3000);
+ final ITmfTimestamp ts2a = TmfTimestamp.fromSeconds(2000);
+ final ITmfTimestamp ts2b = TmfTimestamp.fromSeconds(3000);
final TmfTimeRange range2 = new TmfTimeRange(ts2a, ts2b);
- final ITmfTimestamp ts3a = new TmfTimestamp(3000);
- final ITmfTimestamp ts3b = new TmfTimestamp(4000);
+ final ITmfTimestamp ts3a = TmfTimestamp.fromSeconds(3000);
+ final ITmfTimestamp ts3b = TmfTimestamp.fromSeconds(4000);
final TmfTimeRange range3 = new TmfTimeRange(ts3a, ts3b);
- final ITmfTimestamp ts4a = new TmfTimestamp(1500);
- final ITmfTimestamp ts4b = new TmfTimestamp(2500);
+ final ITmfTimestamp ts4a = TmfTimestamp.fromSeconds(1500);
+ final ITmfTimestamp ts4b = TmfTimestamp.fromSeconds(2500);
final TmfTimeRange range4 = new TmfTimeRange(ts4a, ts4b);
- final ITmfTimestamp ts5a = new TmfTimestamp(1500);
- final ITmfTimestamp ts5b = new TmfTimestamp(2000);
+ final ITmfTimestamp ts5a = TmfTimestamp.fromSeconds(1500);
+ final ITmfTimestamp ts5b = TmfTimestamp.fromSeconds(2000);
final TmfTimeRange range5 = new TmfTimeRange(ts5a, ts5b);
- final ITmfTimestamp ts6a = new TmfTimestamp(2000);
- final ITmfTimestamp ts6b = new TmfTimestamp(2500);
+ final ITmfTimestamp ts6a = TmfTimestamp.fromSeconds(2000);
+ final ITmfTimestamp ts6b = TmfTimestamp.fromSeconds(2500);
final TmfTimeRange range6 = new TmfTimeRange(ts6a, ts6b);
- final ITmfTimestamp ts7a = new TmfTimestamp(1500);
- final ITmfTimestamp ts7b = new TmfTimestamp(3500);
+ final ITmfTimestamp ts7a = TmfTimestamp.fromSeconds(1500);
+ final ITmfTimestamp ts7b = TmfTimestamp.fromSeconds(3500);
final TmfTimeRange range7 = new TmfTimeRange(ts7a, ts7b);
- final ITmfTimestamp ts8a = new TmfTimestamp(2250);
- final ITmfTimestamp ts8b = new TmfTimestamp(2750);
+ final ITmfTimestamp ts8a = TmfTimestamp.fromSeconds(2250);
+ final ITmfTimestamp ts8b = TmfTimestamp.fromSeconds(2750);
final TmfTimeRange range8 = new TmfTimeRange(ts8a, ts8b);
assertEquals("getIntersection (below - not contiguous)", null, range1.getIntersection(range3));
@Test
public void testCopyConstructor() {
- final ITmfTimestamp ts = new TmfTimestamp(12345, 2);
- final ITmfTimestamp copy = new TmfTimestamp(ts);
+ final ITmfTimestamp ts = TmfTimestamp.create(12345, 2);
+ final ITmfTimestamp copy = TmfTimestamp.create(12345, 2);
assertEquals("getValue", ts.getValue(), copy.getValue());
assertEquals("getscale", ts.getScale(), copy.getScale());
assertEquals("getscale", 2, copy.getScale());
}
- @Test(expected=IllegalArgumentException.class)
- public void testCopyNullConstructor() {
- new TmfTimestamp((TmfTimestamp) null);
- }
-
// ------------------------------------------------------------------------
// normalize
// ------------------------------------------------------------------------
// Variables
// ------------------------------------------------------------------------
- private final ITmfTimestamp ts0 = new TmfTimestamp();
- private final ITmfTimestamp ts1 = new TmfTimestamp(12345, 0);
- private final ITmfTimestamp ts2 = new TmfTimestamp(12345, -1);
- private final ITmfTimestamp ts3 = new TmfTimestamp(12345, 2);
- private final ITmfTimestamp ts4 = new TmfTimestamp(12345, -3);
- private final ITmfTimestamp ts5 = new TmfTimestamp(12345, -6);
- private final ITmfTimestamp ts6 = new TmfTimestamp(12345, -9);
- private final ITmfTimestamp ts7 = new TmfTimestamp(-12345, -3);
- private final ITmfTimestamp ts8 = new TmfTimestamp(-12345, -6);
- private final ITmfTimestamp ts9 = new TmfTimestamp(-12345, -9);
- private final ITmfTimestamp ts10 = new TmfTimestamp(Long.MAX_VALUE / 100, -6);
- private final ITmfTimestamp ts11 = new TmfTimestamp(Long.MIN_VALUE / 100, -6);
+ private final ITmfTimestamp ts0 = TmfTimestamp.create(0, ITmfTimestamp.SECOND_SCALE);
+ private final ITmfTimestamp ts1 = TmfTimestamp.create(12345, 0);
+ private final ITmfTimestamp ts2 = TmfTimestamp.create(12345, -1);
+ private final ITmfTimestamp ts3 = TmfTimestamp.create(12345, 2);
+ private final ITmfTimestamp ts4 = TmfTimestamp.create(12345, -3);
+ private final ITmfTimestamp ts5 = TmfTimestamp.create(12345, -6);
+ private final ITmfTimestamp ts6 = TmfTimestamp.create(12345, -9);
+ private final ITmfTimestamp ts7 = TmfTimestamp.create(-12345, -3);
+ private final ITmfTimestamp ts8 = TmfTimestamp.create(-12345, -6);
+ private final ITmfTimestamp ts9 = TmfTimestamp.create(-12345, -9);
+ private final ITmfTimestamp ts10 = TmfTimestamp.create(Long.MAX_VALUE / 100, -6);
+ private final ITmfTimestamp ts11 = TmfTimestamp.create(Long.MIN_VALUE / 100, -6);
// ------------------------------------------------------------------------
// Constructors
@Test
public void testCopyConstructor() {
- final ITmfTimestamp ts = new TmfTimestamp(12345, 2);
- final ITmfTimestamp copy = new TmfTimestamp(ts);
+ final ITmfTimestamp ts = TmfTimestamp.create(12345, 2);
+ final ITmfTimestamp copy = TmfTimestamp.create(ts.getValue(), ts.getScale());
assertEquals("getValue", ts.getValue(), copy.getValue());
assertEquals("getscale", ts.getScale(), copy.getScale());
assertEquals("getscale", 2, copy.getScale());
}
- @Test(expected = IllegalArgumentException.class)
- public void testCopyNullConstructor() {
- new TmfTimestamp((TmfTimestamp) null);
- }
-
@Test
public void testCopyConstructorBigBang() {
- final ITmfTimestamp ts = new TmfTimestamp(TmfTimestamp.BIG_BANG);
+ final ITmfTimestamp ts = TmfTimestamp.create(TmfTimestamp.BIG_BANG.getValue(), TmfTimestamp.BIG_BANG.getScale());
assertEquals("getValue", TmfTimestamp.BIG_BANG.getValue(), ts.getValue());
assertEquals("getscale", TmfTimestamp.BIG_BANG.getScale(), ts.getScale());
}
@Test
public void testCopyConstructorBigCrunch() {
- final ITmfTimestamp ts = new TmfTimestamp(TmfTimestamp.BIG_CRUNCH);
+ final ITmfTimestamp ts = TmfTimestamp.create(TmfTimestamp.BIG_CRUNCH.getValue(), TmfTimestamp.BIG_CRUNCH.getScale());
assertEquals("getValue", TmfTimestamp.BIG_CRUNCH.getValue(), ts.getValue());
assertEquals("getscale", TmfTimestamp.BIG_CRUNCH.getScale(), ts.getScale());
}
@Test
public void testCopyConstructorZero() {
- final ITmfTimestamp ts = new TmfTimestamp(TmfTimestamp.ZERO);
+ final ITmfTimestamp ts = TmfTimestamp.create(TmfTimestamp.ZERO.getValue(), TmfTimestamp.ZERO.getScale());
assertEquals("getValue", TmfTimestamp.ZERO.getValue(), ts.getValue());
assertEquals("getscale", TmfTimestamp.ZERO.getScale(), ts.getScale());
}
@Test
public void testHashCode() {
- final ITmfTimestamp ts0copy = new TmfTimestamp(ts0);
- final ITmfTimestamp ts1copy = new TmfTimestamp(ts1);
- final ITmfTimestamp ts2copy = new TmfTimestamp(ts2);
+ final ITmfTimestamp ts0copy = TmfTimestamp.create(ts0.getValue(), ts0.getScale());
+ final ITmfTimestamp ts1copy = TmfTimestamp.create(ts1.getValue(), ts1.getScale());
+ final ITmfTimestamp ts2copy = TmfTimestamp.create(ts2.getValue(), ts2.getScale());
- assertTrue("hashCode", ts0.hashCode() == ts0copy.hashCode());
- assertTrue("hashCode", ts1.hashCode() == ts1copy.hashCode());
- assertTrue("hashCode", ts2.hashCode() == ts2copy.hashCode());
+ assertEquals("hashCode", ts0.hashCode(), ts0copy.hashCode());
+ assertEquals("hashCode", ts1.hashCode(), ts1copy.hashCode());
+ assertEquals("hashCode", ts2.hashCode(), ts2copy.hashCode());
assertTrue("hashCode", ts0.hashCode() != ts1.hashCode());
}
@Test
public void testEqualsReflexivity() {
- assertTrue("equals", ts0.equals(ts0));
- assertTrue("equals", ts1.equals(ts1));
+ assertEquals("equals", ts0, ts0);
+ assertEquals("equals", ts1, ts1);
- assertTrue("equals", !ts0.equals(ts1));
- assertTrue("equals", !ts1.equals(ts0));
+ assertFalse("Different", ts0.equals(ts1));
+ assertFalse("Different", ts1.equals(ts0));
}
@Test
public void testEqualsSymmetry() {
- final ITmfTimestamp ts0copy = new TmfTimestamp(ts0);
- assertTrue("equals", ts0.equals(ts0copy));
- assertTrue("equals", ts0copy.equals(ts0));
+ final ITmfTimestamp ts0copy = TmfTimestamp.create(ts0.getValue(), ts0.getScale());
+ assertEquals("equals", ts0, ts0copy);
+ assertEquals("equals", ts0copy, ts0);
- final ITmfTimestamp ts1copy = new TmfTimestamp(ts1);
- assertTrue("equals", ts1.equals(ts1copy));
- assertTrue("equals", ts1copy.equals(ts1));
+ final ITmfTimestamp ts1copy = TmfTimestamp.create(ts1.getValue(), ts1.getScale());
+ assertEquals("equals", ts1, ts1copy);
+ assertEquals("equals", ts1copy, ts1);
- final ITmfTimestamp ts2copy = new TmfTimestamp(ts2);
- assertTrue("equals", ts2.equals(ts2copy));
- assertTrue("equals", ts2copy.equals(ts2));
+ final ITmfTimestamp ts2copy = TmfTimestamp.create(ts2.getValue(), ts2.getScale());
+ assertEquals("equals", ts2, ts2copy);
+ assertEquals("equals", ts2copy, ts2);
}
@Test
public void testEqualsTransivity() {
- final ITmfTimestamp ts0copy1 = new TmfTimestamp(ts0);
- final ITmfTimestamp ts0copy2 = new TmfTimestamp(ts0copy1);
+ final ITmfTimestamp ts0copy1 = TmfTimestamp.create(ts0.getValue(), ts0.getScale());
+ final ITmfTimestamp ts0copy2 = TmfTimestamp.create(ts0copy1.getValue(), ts0copy1.getScale());
assertTrue("equals", ts0.equals(ts0copy1));
assertTrue("equals", ts0copy1.equals(ts0copy2));
assertTrue("equals", ts0.equals(ts0copy2));
- final ITmfTimestamp ts1copy1 = new TmfTimestamp(ts1);
- final ITmfTimestamp ts1copy2 = new TmfTimestamp(ts1copy1);
+ final ITmfTimestamp ts1copy1 = TmfTimestamp.create(ts1.getValue(), ts1.getScale());
+ final ITmfTimestamp ts1copy2 = TmfTimestamp.create(ts1copy1.getValue(), ts1copy1.getScale());
assertTrue("equals", ts1.equals(ts1copy1));
assertTrue("equals", ts1copy1.equals(ts1copy2));
assertTrue("equals", ts1.equals(ts1copy2));
- final ITmfTimestamp ts2copy1 = new TmfTimestamp(ts2);
- final ITmfTimestamp ts2copy2 = new TmfTimestamp(ts2copy1);
+ final ITmfTimestamp ts2copy1 = TmfTimestamp.create(ts2.getValue(), ts2.getScale());
+ final ITmfTimestamp ts2copy2 = TmfTimestamp.create(ts2copy1.getValue(), ts2copy1.getScale());
assertTrue("equals", ts2.equals(ts2copy1));
assertTrue("equals", ts2copy1.equals(ts2copy2));
assertTrue("equals", ts2.equals(ts2copy2));
@Test
public void testNormalizeOffsetLowerLimits() {
- final ITmfTimestamp ref = new TmfTimestamp(Long.MIN_VALUE + 5, 0);
+ final ITmfTimestamp ref = TmfTimestamp.create(Long.MIN_VALUE + 5, 0);
ITmfTimestamp ts = ref.normalize(-4, 0);
assertEquals("getValue", Long.MIN_VALUE + 1, ts.getValue());
@Test
public void testNormalizeOffsetUpperLimits() {
- final ITmfTimestamp ref = new TmfTimestamp(Long.MAX_VALUE - 5, 0);
+ final ITmfTimestamp ref = TmfTimestamp.create(Long.MAX_VALUE - 5, 0);
ITmfTimestamp ts = ref.normalize(4, 0);
assertEquals("getValue", Long.MAX_VALUE - 1, ts.getValue());
@Test
public void testBasicCompareTo() {
- final ITmfTimestamp t1 = new TmfTimestamp(900, 0);
- final ITmfTimestamp t2 = new TmfTimestamp(1000, 0);
- final ITmfTimestamp t3 = new TmfTimestamp(1100, 0);
- final ITmfTimestamp t4 = new TmfTimestamp(1000, 0);
+ final ITmfTimestamp t1 = TmfTimestamp.create(900, 0);
+ final ITmfTimestamp t2 = TmfTimestamp.create(1000, 0);
+ final ITmfTimestamp t3 = TmfTimestamp.create(1100, 0);
+ final ITmfTimestamp t4 = TmfTimestamp.create(1000, 0);
assertTrue(t1.compareTo(t1) == 0);
@Test
public void testCompareToCornerCases1() {
- final ITmfTimestamp ts0a = new TmfTimestamp(ts0);
- final ITmfTimestamp ts0b = new TmfTimestamp(ts0.getValue(), ts0.getScale() + 1);
- final ITmfTimestamp ts0c = new TmfTimestamp(ts0.getValue() + 1, ts0.getScale());
- final ITmfTimestamp ts0d = new TmfTimestamp(ts0.getValue() + 1, ts0.getScale() + 1);
+ final ITmfTimestamp ts0a = TmfTimestamp.create(ts0.getValue(), ts0.getScale());
+ final ITmfTimestamp ts0b = TmfTimestamp.create(ts0.getValue(), ts0.getScale() + 1);
+ final ITmfTimestamp ts0c = TmfTimestamp.create(ts0.getValue() + 1, ts0.getScale());
+ final ITmfTimestamp ts0d = TmfTimestamp.create(ts0.getValue() + 1, ts0.getScale() + 1);
assertTrue("compareTo", ts0.compareTo(ts0) == 0);
assertTrue("compareTo", ts0.compareTo(ts0a) == 0);
@Test
public void testCompareToCornerCases2() {
- final ITmfTimestamp ts0a = new TmfTimestamp(Long.MAX_VALUE, Integer.MAX_VALUE - 1);
- final ITmfTimestamp ts0b = new TmfTimestamp(0, Integer.MAX_VALUE);
- final ITmfTimestamp ts0c = new TmfTimestamp(Long.MAX_VALUE, Integer.MAX_VALUE);
+ final ITmfTimestamp ts0a = TmfTimestamp.create(Long.MAX_VALUE, Integer.MAX_VALUE - 1);
+ final ITmfTimestamp ts0b = TmfTimestamp.create(0, Integer.MAX_VALUE);
+ final ITmfTimestamp ts0c = TmfTimestamp.create(Long.MAX_VALUE, Integer.MAX_VALUE);
assertEquals("compareTo", 1, ts0a.compareTo(ts0b));
assertEquals("compareTo", -1, ts0a.compareTo(ts0c));
@Test
public void testCompareToCornerCases3() {
- final ITmfTimestamp ts0a = new TmfTimestamp(Long.MIN_VALUE, Integer.MAX_VALUE - 1);
- final ITmfTimestamp ts0b = new TmfTimestamp(0, Integer.MAX_VALUE);
- final ITmfTimestamp ts0c = new TmfTimestamp(Long.MIN_VALUE, Integer.MAX_VALUE);
+ final ITmfTimestamp ts0a = TmfTimestamp.create(Long.MIN_VALUE, Integer.MAX_VALUE - 1);
+ final ITmfTimestamp ts0b = TmfTimestamp.create(0, Integer.MAX_VALUE);
+ final ITmfTimestamp ts0c = TmfTimestamp.create(Long.MIN_VALUE, Integer.MAX_VALUE);
assertEquals("compareTo", -1, ts0a.compareTo(ts0b));
assertEquals("compareTo", 1, ts0a.compareTo(ts0c));
@Test
public void testCompareToSameScale() {
- final ITmfTimestamp t1 = new TmfTimestamp(900, 0);
- final ITmfTimestamp t2 = new TmfTimestamp(1000, 0);
- final ITmfTimestamp t3 = new TmfTimestamp(1100, 0);
- final ITmfTimestamp t4 = new TmfTimestamp(1000, 0);
+ final ITmfTimestamp t1 = TmfTimestamp.create(900, 0);
+ final ITmfTimestamp t2 = TmfTimestamp.create(1000, 0);
+ final ITmfTimestamp t3 = TmfTimestamp.create(1100, 0);
+ final ITmfTimestamp t4 = TmfTimestamp.create(1000, 0);
assertEquals(0, t1.compareTo(t1));
@Test
public void testCompareToDifferentScale() {
- final ITmfTimestamp t1 = new TmfTimestamp(9000, -1);
- final ITmfTimestamp t2 = new TmfTimestamp(1000, 0);
- final ITmfTimestamp t3 = new TmfTimestamp(110, 1);
- final ITmfTimestamp t4 = new TmfTimestamp(1, 3);
+ final ITmfTimestamp t1 = TmfTimestamp.create(9000, -1);
+ final ITmfTimestamp t2 = TmfTimestamp.create(1000, 0);
+ final ITmfTimestamp t3 = TmfTimestamp.create(110, 1);
+ final ITmfTimestamp t4 = TmfTimestamp.create(1, 3);
assertTrue("CompareTo", t1.compareTo(t1) == 0);
@Test
public void testCompareToLargeScale1() {
- final ITmfTimestamp t1 = new TmfTimestamp(-1, 100);
- final ITmfTimestamp t2 = new TmfTimestamp(-1000, -100);
- final ITmfTimestamp t3 = new TmfTimestamp(1, 100);
- final ITmfTimestamp t4 = new TmfTimestamp(1000, -100);
+ final ITmfTimestamp t1 = TmfTimestamp.create(-1, 100);
+ final ITmfTimestamp t2 = TmfTimestamp.create(-1000, -100);
+ final ITmfTimestamp t3 = TmfTimestamp.create(1, 100);
+ final ITmfTimestamp t4 = TmfTimestamp.create(1000, -100);
assertEquals("CompareTo", -1, t1.compareTo(t2));
assertTrue("CompareTo", t1.compareTo(t3) < 0);
@Test
public void testCompareToLargeScale2() {
- final ITmfTimestamp ts0a = new TmfTimestamp(0, Integer.MAX_VALUE);
- final ITmfTimestamp ts0b = new TmfTimestamp(1, Integer.MAX_VALUE);
+ final ITmfTimestamp ts0a = TmfTimestamp.create(0, Integer.MAX_VALUE);
+ final ITmfTimestamp ts0b = TmfTimestamp.create(1, Integer.MAX_VALUE);
assertEquals("CompareTo", 0, ts0a.compareTo(ts0));
assertEquals("CompareTo", 0, ts0.compareTo(ts0a));
@Test
public void testDelta() {
// Delta for same scale and precision (delta > 0)
- ITmfTimestamp t0 = new TmfTimestamp(10, 9);
- ITmfTimestamp t1 = new TmfTimestamp(5, 9);
- ITmfTimestamp exp = new TmfTimestamp(5, 9);
+ ITmfTimestamp t0 = TmfTimestamp.create(10, 9);
+ ITmfTimestamp t1 = TmfTimestamp.create(5, 9);
+ ITmfTimestamp exp = TmfTimestamp.create(5, 9);
ITmfTimestamp delta = t0.getDelta(t1);
assertEquals("getDelta", 0, delta.compareTo(exp));
// Delta for same scale and precision (delta < 0)
- t0 = new TmfTimestamp(5, 9);
- t1 = new TmfTimestamp(10, 9);
- exp = new TmfTimestamp(-5, 9);
+ t0 = TmfTimestamp.create(5, 9);
+ t1 = TmfTimestamp.create(10, 9);
+ exp = TmfTimestamp.create(-5, 9);
delta = t0.getDelta(t1);
assertEquals("getDelta", 0, delta.compareTo(exp));
// Delta for different scale and same precision (delta > 0)
- t0 = new TmfTimestamp(5, 9);
- t1 = new TmfTimestamp(10, 8);
- exp = new TmfTimestamp(4, 9);
+ t0 = TmfTimestamp.create(5, 9);
+ t1 = TmfTimestamp.create(10, 8);
+ exp = TmfTimestamp.create(4, 9);
delta = t0.getDelta(t1);
assertEquals("getDelta", 0, delta.compareTo(exp));
// Delta for different scale and same precision (delta > 0)
- t0 = new TmfTimestamp(5, 9);
- t1 = new TmfTimestamp(10, 7);
- exp = new TmfTimestamp(5, 9);
+ t0 = TmfTimestamp.create(5, 9);
+ t1 = TmfTimestamp.create(10, 7);
+ exp = TmfTimestamp.create(5, 9);
delta = t0.getDelta(t1);
assertEquals("getDelta", 0, delta.compareTo(exp));
// Delta for different scale and same precision
- t0 = new TmfTimestamp(10, 9);
- t1 = new TmfTimestamp(5, 8);
- exp = new TmfTimestamp(10, 9);
+ t0 = TmfTimestamp.create(10, 9);
+ t1 = TmfTimestamp.create(5, 8);
+ exp = TmfTimestamp.create(10, 9);
delta = t0.getDelta(t1);
assertEquals("getDelta", 0, delta.compareTo(exp));
// Delta for same scale
- t0 = new TmfTimestamp(10, 9);
- t1 = new TmfTimestamp(5, 9);
- exp = new TmfTimestamp(5, 9);
+ t0 = TmfTimestamp.create(10, 9);
+ t1 = TmfTimestamp.create(5, 9);
+ exp = TmfTimestamp.create(5, 9);
delta = t0.getDelta(t1);
assertEquals("getDelta", 0, delta.compareTo(exp));
// Delta for different scale
- t0 = new TmfTimestamp(5, 9);
- t1 = new TmfTimestamp(10, 8);
- exp = new TmfTimestamp(4, 9);
+ t0 = TmfTimestamp.create(5, 9);
+ t1 = TmfTimestamp.create(10, 8);
+ exp = TmfTimestamp.create(4, 9);
delta = t0.getDelta(t1);
assertEquals("getDelta", 0, delta.compareTo(exp));
}
import org.eclipse.tracecompass.tmf.core.event.collapse.ITmfCollapsibleEvent;
import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestTrace;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.junit.After;
@Override
public ITmfTimestamp getTimestamp() {
- return new TmfNanoTimestamp(100);
+ return TmfTimestamp.fromNanos(100);
}
@Override
import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterMatchesNode;
import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterOrNode;
import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterTraceTypeNode;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.junit.Before;
import org.junit.Test;
// ------------------------------------------------------------------------
private ITmfEventField fContent = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, null);
- private TmfEvent fEvent = new TmfEvent(TRACE, 0, new TmfNanoTimestamp(1), EVENT_TYPE, fContent);
+ private TmfEvent fEvent = new TmfEvent(TRACE, 0, TmfTimestamp.fromNanos(1), EVENT_TYPE, fContent);
private TmfFilterAndNode fFilter;
// ------------------------------------------------------------------------
import org.eclipse.tracecompass.tmf.core.event.aspect.TmfContentFieldAspect;
import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterCompareNode;
import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterCompareNode.Type;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.junit.Before;
import org.junit.Test;
private ITmfEventField fContent1 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, fFields1);
private ITmfEventField fContent2 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, fFields2);
private ITmfEventField fContent3 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, fFields3);
- private TmfEvent fEvent1 = new TmfEvent(TRACE, 0, new TmfNanoTimestamp(1), EVENT_TYPE, fContent1);
- private TmfEvent fEvent2 = new TmfEvent(TRACE, 1, new TmfNanoTimestamp(2), EVENT_TYPE, fContent2);
- private TmfEvent fEvent3 = new TmfEvent(TRACE, 2, new TmfNanoTimestamp(3), EVENT_TYPE, fContent3);
+ private TmfEvent fEvent1 = new TmfEvent(TRACE, 0, TmfTimestamp.fromNanos(1), EVENT_TYPE, fContent1);
+ private TmfEvent fEvent2 = new TmfEvent(TRACE, 1, TmfTimestamp.fromNanos(2), EVENT_TYPE, fContent2);
+ private TmfEvent fEvent3 = new TmfEvent(TRACE, 2, TmfTimestamp.fromNanos(3), EVENT_TYPE, fContent3);
private TmfFilterCompareNode fFilter;
// ------------------------------------------------------------------------
import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
import org.eclipse.tracecompass.tmf.core.event.aspect.TmfContentFieldAspect;
import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterContainsNode;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.junit.Before;
import org.junit.Test;
private ITmfEventField[] fFields2 = new ITmfEventField[] { new TmfEventField(FIELD, "value 2", null) };
private ITmfEventField fContent1 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, fFields1);
private ITmfEventField fContent2 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, fFields2);
- private TmfEvent fEvent1 = new TmfEvent(TRACE, 0, new TmfNanoTimestamp(1), EVENT_TYPE, fContent1);
- private TmfEvent fEvent2 = new TmfEvent(TRACE, 1, new TmfNanoTimestamp(2), EVENT_TYPE, fContent2);
+ private TmfEvent fEvent1 = new TmfEvent(TRACE, 0, TmfTimestamp.fromNanos(1), EVENT_TYPE, fContent1);
+ private TmfEvent fEvent2 = new TmfEvent(TRACE, 1, TmfTimestamp.fromNanos(2), EVENT_TYPE, fContent2);
private TmfFilterContainsNode fFilter;
// ------------------------------------------------------------------------
import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
import org.eclipse.tracecompass.tmf.core.event.aspect.TmfContentFieldAspect;
import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterEqualsNode;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.junit.Before;
import org.junit.Test;
private ITmfEventField[] fFields2 = new ITmfEventField[] { new TmfEventField(FIELD, "value 2", null) };
private ITmfEventField fContent1 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, fFields1);
private ITmfEventField fContent2 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, fFields2);
- private TmfEvent fEvent1 = new TmfEvent(TRACE, 0, new TmfNanoTimestamp(1), EVENT_TYPE, fContent1);
- private TmfEvent fEvent2 = new TmfEvent(TRACE, 1, new TmfNanoTimestamp(2), EVENT_TYPE, fContent2);
+ private TmfEvent fEvent1 = new TmfEvent(TRACE, 0, TmfTimestamp.fromNanos(1), EVENT_TYPE, fContent1);
+ private TmfEvent fEvent2 = new TmfEvent(TRACE, 1, TmfTimestamp.fromNanos(2), EVENT_TYPE, fContent2);
private TmfFilterEqualsNode fFilter;
// ------------------------------------------------------------------------
import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
import org.eclipse.tracecompass.tmf.core.event.aspect.TmfContentFieldAspect;
import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterMatchesNode;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.junit.Before;
import org.junit.Test;
private ITmfEventField[] fFields2 = new ITmfEventField[] { new TmfEventField(FIELD, "value 2", null) };
private ITmfEventField fContent1 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, fFields1);
private ITmfEventField fContent2 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, fFields2);
- private TmfEvent fEvent1 = new TmfEvent(TRACE, 0, new TmfNanoTimestamp(1), EVENT_TYPE, fContent1);
- private TmfEvent fEvent2 = new TmfEvent(TRACE, 1, new TmfNanoTimestamp(2), EVENT_TYPE, fContent2);
+ private TmfEvent fEvent1 = new TmfEvent(TRACE, 0, TmfTimestamp.fromNanos(1), EVENT_TYPE, fContent1);
+ private TmfEvent fEvent2 = new TmfEvent(TRACE, 1, TmfTimestamp.fromNanos(2), EVENT_TYPE, fContent2);
private TmfFilterMatchesNode fFilter;
// ------------------------------------------------------------------------
import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterNode;
import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterOrNode;
import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterTraceTypeNode;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.junit.Before;
import org.junit.Test;
private static final String FILTER = "filter";
private ITmfEventField fContent = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, null);
- private TmfEvent fEvent = new TmfEvent(TRACE, 0, new TmfNanoTimestamp(1), EVENT_TYPE, fContent);
+ private TmfEvent fEvent = new TmfEvent(TRACE, 0, TmfTimestamp.fromNanos(1), EVENT_TYPE, fContent);
private TmfFilterNode fFilter;
// ------------------------------------------------------------------------
import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterMatchesNode;
import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterOrNode;
import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterTraceTypeNode;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.junit.Before;
import org.junit.Test;
// ------------------------------------------------------------------------
private ITmfEventField fContent = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, null);
- private TmfEvent fEvent = new TmfEvent(TRACE, 0, new TmfNanoTimestamp(1), EVENT_TYPE, fContent);
+ private TmfEvent fEvent = new TmfEvent(TRACE, 0, TmfTimestamp.fromNanos(1), EVENT_TYPE, fContent);
private TmfFilterOrNode fFilter;
// ------------------------------------------------------------------------
import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterNode;
import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterRootNode;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.junit.Before;
import org.junit.Test;
// ------------------------------------------------------------------------
private ITmfEventField fContent = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, null);
- private TmfEvent fEvent = new TmfEvent(TRACE, 0, new TmfNanoTimestamp(1), EVENT_TYPE, fContent);
+ private TmfEvent fEvent = new TmfEvent(TRACE, 0, TmfTimestamp.fromNanos(1), EVENT_TYPE, fContent);
private TmfFilterRootNode fFilter;
// ------------------------------------------------------------------------
import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlInputElement;
import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTrace;
import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTraceDefinition;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub;
import org.junit.AfterClass;
import org.junit.Before;
private static TmfEventType fCustomTxtEventType = new CustomTxtEventType(fCustomTxtDefinition);
private static TmfEventType fCustomXmlEventType = new CustomXmlEventType(fCustomXmlDefinition);
private ITmfEventField fContent = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, null);
- private TmfEvent fEvent1 = new TmfEvent(TRACE, 0, new TmfNanoTimestamp(1), EVENT_TYPE, fContent);
- private TmfEvent fEvent2 = new CustomTxtEvent(fCustomTxtDefinition, fCustomTxtTrace, new TmfNanoTimestamp(2), fCustomTxtEventType);
- private TmfEvent fEvent3 = new CustomXmlEvent(fCustomXmlDefinition, fCustomXmlTrace, new TmfNanoTimestamp(3), fCustomXmlEventType);
+ private TmfEvent fEvent1 = new TmfEvent(TRACE, 0, TmfTimestamp.fromNanos(1), EVENT_TYPE, fContent);
+ private TmfEvent fEvent2 = new CustomTxtEvent(fCustomTxtDefinition, fCustomTxtTrace, TmfTimestamp.fromNanos(2), fCustomTxtEventType);
+ private TmfEvent fEvent3 = new CustomXmlEvent(fCustomXmlDefinition, fCustomXmlTrace, TmfTimestamp.fromNanos(3), fCustomXmlEventType);
private TmfFilterTraceTypeNode fFilter;
@AfterClass
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
import org.eclipse.tracecompass.tmf.core.tests.TmfCoreTestPlugin;
import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestTrace;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub;
// ------------------------------------------------------------------------
private final TmfTimeRange range1 = TmfTimeRange.ETERNITY;
- private final TmfTimeRange range2 = new TmfTimeRange(new TmfTimestamp(), TmfTimestamp.BIG_CRUNCH);
+ private final TmfTimeRange range2 = new TmfTimeRange(TmfTimestamp.create(0, ITmfTimestamp.SECOND_SCALE), TmfTimestamp.BIG_CRUNCH);
private TmfCoalescedEventRequest fRequest1;
private TmfCoalescedEventRequest fRequest2;
*/
@TmfSignalHandler
public void trigger(final TmfTestTriggerSignal2 signal) {
- TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(100, -3), TmfTimestamp.BIG_CRUNCH);
+ TmfTimeRange range = new TmfTimeRange(TmfTimestamp.create(100, -3), TmfTimestamp.BIG_CRUNCH);
requestedEvents1 = new Vector<>();
request1 = new TmfEventRequest(ITmfEvent.class, range, 0, 1, ExecutionType.FOREGROUND) {
@Override
// ------------------------------------------------------------------------
private static TmfTimeRange range1 = TmfTimeRange.ETERNITY;
- private static TmfTimeRange range2 = new TmfTimeRange(new TmfTimestamp(), TmfTimestamp.BIG_CRUNCH);
+ private static TmfTimeRange range2 = new TmfTimeRange(TmfTimestamp.fromSeconds(0), TmfTimestamp.BIG_CRUNCH);
private static TmfEventRequest fRequest1;
private static TmfEventRequest fRequest2;
@Test
public void testTmfEventRequestTimeRange() {
- TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(), TmfTimestamp.BIG_CRUNCH);
+ TmfTimeRange range = new TmfTimeRange(TmfTimestamp.fromSeconds(0), TmfTimestamp.BIG_CRUNCH);
TmfEventRequest request = new TmfEventRequestStub(ITmfEvent.class, range);
assertEquals("getDataType", ITmfEvent.class, request.getDataType());
- assertEquals("StartTime", new TmfTimestamp(), request.getRange().getStartTime());
+ assertEquals("StartTime", TmfTimestamp.fromSeconds(0), request.getRange().getStartTime());
assertEquals("EndTime", TmfTimestamp.BIG_CRUNCH, request.getRange().getEndTime());
assertEquals("getIndex", 0, request.getIndex());
@Test
public void testTmfEventRequestTimeRangeNbRequested() {
- TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(), TmfTimestamp.BIG_CRUNCH);
+ TmfTimeRange range = new TmfTimeRange(TmfTimestamp.fromSeconds(0), TmfTimestamp.BIG_CRUNCH);
TmfEventRequest request = new TmfEventRequestStub(ITmfEvent.class, range, 100);
assertEquals("getDataType", ITmfEvent.class, request.getDataType());
- assertEquals("StartTime", new TmfTimestamp(), request.getRange().getStartTime());
+ assertEquals("StartTime", TmfTimestamp.fromSeconds(0), request.getRange().getStartTime());
assertEquals("EndTime", TmfTimestamp.BIG_CRUNCH, request.getRange().getEndTime());
assertEquals("getIndex", 0, request.getIndex());
@Test
public void testTmfEventRequestTimeRangeNbRequestedBlocksize() {
- TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(), TmfTimestamp.BIG_CRUNCH);
+ TmfTimeRange range = new TmfTimeRange(TmfTimestamp.fromSeconds(0), TmfTimestamp.BIG_CRUNCH);
TmfEventRequest request = new TmfEventRequestStub(ITmfEvent.class, range, 100, 200);
assertEquals("getDataType", ITmfEvent.class, request.getDataType());
- assertEquals("StartTime", new TmfTimestamp(), request.getRange().getStartTime());
+ assertEquals("StartTime", TmfTimestamp.fromSeconds(0), request.getRange().getStartTime());
assertEquals("EndTime", TmfTimestamp.BIG_CRUNCH, request.getRange().getEndTime());
assertEquals("getIndex", 0, request.getIndex());
import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub;
} else {
value = TmfStateValue.nullValue();
}
- ITmfTimestamp timestamp = new TmfNanoTimestamp(time);
+ ITmfTimestamp timestamp = TmfTimestamp.fromNanos(time);
ITmfEventType eventType = new TmfEventType(MIPMAP_ID, null);
ITmfEventField content = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, value, null);
ITmfEvent event = new TmfEvent(null, ITmfContext.UNKNOWN_RANK, timestamp, eventType, content);
import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException;
import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
-import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue.Type;
+import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
import org.junit.BeforeClass;
import org.junit.Test;
private static void addSyncMatch(SynchronizationAlgorithm algo, ITmfTrace sender, long sendTs, ITmfTrace receiver, long receiveTs) {
algo.addMatch(
new TmfEventDependency(
- new TmfSyncEventStub(sender, new TmfTimestamp(sendTs)),
- new TmfSyncEventStub(receiver, new TmfTimestamp(receiveTs))
+ new TmfSyncEventStub(sender, TmfTimestamp.fromSeconds(sendTs)),
+ new TmfSyncEventStub(receiver, TmfTimestamp.fromSeconds(receiveTs))
));
}
import org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform;
import org.eclipse.tracecompass.tmf.core.synchronization.TimestampTransformFactory;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.junit.Test;
*/
@NonNullByDefault
public class TsTransformFactoryTest {
- private final ITmfTimestamp t0 = new TmfTimestamp(0);
- private final ITmfTimestamp t100 = new TmfTimestamp(100);
- private final ITmfTimestamp t1e2 = new TmfTimestamp(1, 2);
- private final ITmfTimestamp t1e3 = new TmfTimestamp(1, 3);
- private final ITmfTimestamp tn0 = new TmfNanoTimestamp(0);
- private final ITmfTimestamp tn100 = new TmfNanoTimestamp(100);
- private final ITmfTimestamp tn1 = new TmfNanoTimestamp(1);
- private final ITmfTimestampTransform identity1 = TimestampTransformFactory.createLinear(1.0, new TmfNanoTimestamp(0));
+ private final ITmfTimestamp t0 = TmfTimestamp.fromSeconds(0);
+ private final ITmfTimestamp t100 = TmfTimestamp.fromSeconds(100);
+ private final ITmfTimestamp t1e2 = TmfTimestamp.create(1, 2);
+ private final ITmfTimestamp t1e3 = TmfTimestamp.create(1, 3);
+ private final ITmfTimestamp tn0 = TmfTimestamp.fromNanos(0);
+ private final ITmfTimestamp tn100 = TmfTimestamp.fromNanos(100);
+ private final ITmfTimestamp tn1 = TmfTimestamp.fromNanos(1);
+ private final ITmfTimestampTransform identity1 = TimestampTransformFactory.createLinear(1.0, TmfTimestamp.fromNanos(0));
private final ITmfTimestampTransform offset1 = TimestampTransformFactory.createWithOffset(100);
private final ITmfTimestampTransform offset2 = TimestampTransformFactory.createLinear(NonNullUtils.checkNotNull(BigDecimal.ONE), NonNullUtils.checkNotNull(new BigDecimal(100)));
private final ITmfTimestampTransform offset3 = TimestampTransformFactory.createLinear(1.0, 100);
- private final ITmfTimestampTransform offset4 = TimestampTransformFactory.createLinear(1.0, new TmfNanoTimestamp(100));
+ private final ITmfTimestampTransform offset4 = TimestampTransformFactory.createLinear(1.0, TmfTimestamp.fromNanos(100));
/**
* Test with identity
@Test
public void transformOffset() {
final ITmfTimestampTransform offset = offset1;
- final ITmfTimestampTransform compositeTransform = offset.composeWith(TimestampTransformFactory.createWithOffset(new TmfNanoTimestamp(-100)));
+ 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));
@Test
public void transformSlope() {
final ITmfTimestampTransform slope = TimestampTransformFactory.createLinear(10, 0);
- final ITmfTimestampTransform slope1 = TimestampTransformFactory.createLinear(10.0, new TmfNanoTimestamp(0));
+ final ITmfTimestampTransform slope1 = TimestampTransformFactory.createLinear(10.0, TmfTimestamp.fromNanos(0));
assertEquals(t1e3, slope.transform(t1e2));
- assertEquals(tn100, slope.transform(new TmfNanoTimestamp(10)));
+ 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(new TmfNanoTimestamp(10)));
+ assertEquals(tn100, slope1.transform(TmfTimestamp.fromNanos(10)));
}
/**
public class TsTransformTest {
private static final long ts = 1361657893526374091L;
- private static final @NonNull ITmfTimestamp oTs = new TmfTimestamp(ts);
+ private static final @NonNull ITmfTimestamp oTs = TmfTimestamp.fromSeconds(ts);
/**
* Test the linear transform
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.core.trace.TmfContext;
// ------------------------------------------------------------------------
private final Long aLong = 12345L;
- private final TmfTimestamp aTimestamp = new TmfTimestamp();
+ private final ITmfTimestamp aTimestamp = TmfTimestamp.fromSeconds(0);
private final TmfLongLocation fLocation1 = new TmfLongLocation(aLong);
private final TmfTimestampLocation fLocation2 = new TmfTimestampLocation(aTimestamp);
@Test
public void testGetTimestamp() {
- assertEquals("getTimestamp", new TmfTimestamp( 1, (byte) -3), fExperiment.getTimestamp( 0));
- assertEquals("getTimestamp", new TmfTimestamp( 2, (byte) -3), fExperiment.getTimestamp( 1));
- assertEquals("getTimestamp", new TmfTimestamp( 11, (byte) -3), fExperiment.getTimestamp( 10));
- assertEquals("getTimestamp", new TmfTimestamp( 101, (byte) -3), fExperiment.getTimestamp( 100));
- assertEquals("getTimestamp", new TmfTimestamp( 1001, (byte) -3), fExperiment.getTimestamp(1000));
- assertEquals("getTimestamp", new TmfTimestamp( 2001, (byte) -3), fExperiment.getTimestamp(2000));
- assertEquals("getTimestamp", new TmfTimestamp( 2501, (byte) -3), fExperiment.getTimestamp(2500));
- assertEquals("getTimestamp", new TmfTimestamp(10000, (byte) -3), fExperiment.getTimestamp(9999));
+ assertEquals("getTimestamp", TmfTimestamp.create( 1, (byte) -3), fExperiment.getTimestamp( 0));
+ assertEquals("getTimestamp", TmfTimestamp.create( 2, (byte) -3), fExperiment.getTimestamp( 1));
+ assertEquals("getTimestamp", TmfTimestamp.create( 11, (byte) -3), fExperiment.getTimestamp( 10));
+ assertEquals("getTimestamp", TmfTimestamp.create( 101, (byte) -3), fExperiment.getTimestamp( 100));
+ assertEquals("getTimestamp", TmfTimestamp.create( 1001, (byte) -3), fExperiment.getTimestamp(1000));
+ assertEquals("getTimestamp", TmfTimestamp.create( 2001, (byte) -3), fExperiment.getTimestamp(2000));
+ assertEquals("getTimestamp", TmfTimestamp.create( 2501, (byte) -3), fExperiment.getTimestamp(2500));
+ assertEquals("getTimestamp", TmfTimestamp.create(10000, (byte) -3), fExperiment.getTimestamp(9999));
assertNull("getTimestamp", fExperiment.getTimestamp(10000));
}
long cacheSize = fExperiment.getCacheSize();
// Position trace at event rank 0
- ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(1, SCALE));
+ ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(1, SCALE));
assertEquals("Context rank", 0, context.getRank());
ITmfEvent event = fExperiment.getNext(context);
assertEquals("Context rank", 1, context.getRank());
// Position trace at event rank [cacheSize]
- context = fExperiment.seekEvent(new TmfTimestamp(cacheSize + 1, SCALE));
+ context = fExperiment.seekEvent(TmfTimestamp.create(cacheSize + 1, SCALE));
assertEquals("Event rank", cacheSize, context.getRank());
event = fExperiment.getNext(context);
assertEquals("Context rank", cacheSize + 1, context.getRank());
// Position trace at event rank [4 * cacheSize]
- context = fExperiment.seekEvent(new TmfTimestamp(4 * cacheSize + 1, SCALE));
+ context = fExperiment.seekEvent(TmfTimestamp.create(4 * cacheSize + 1, SCALE));
assertEquals("Context rank", 4 * cacheSize, context.getRank());
event = fExperiment.getNext(context);
@Test
public void testSeekTimestampNotOnCacheBoundary() {
// Position trace at event rank 1 (TS = 2)
- ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(2, SCALE));
+ ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(2, SCALE));
assertEquals("Context rank", 1, context.getRank());
ITmfEvent event = fExperiment.getNext(context);
assertEquals("Context rank", 2, context.getRank());
// Position trace at event rank 9 (TS = 10)
- context = fExperiment.seekEvent(new TmfTimestamp(10, SCALE));
+ context = fExperiment.seekEvent(TmfTimestamp.create(10, SCALE));
assertEquals("Context rank", 9, context.getRank());
event = fExperiment.getNext(context);
assertEquals("Context rank", 10, context.getRank());
// Position trace at event rank 999 (TS = 1000)
- context = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE));
+ context = fExperiment.seekEvent(TmfTimestamp.create(1000, SCALE));
assertEquals("Context rank", 999, context.getRank());
event = fExperiment.getNext(context);
assertEquals("Context rank", 1000, context.getRank());
// Position trace at event rank 1001 (TS = 1002)
- context = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE));
+ context = fExperiment.seekEvent(TmfTimestamp.create(1002, SCALE));
assertEquals("Context rank", 1001, context.getRank());
event = fExperiment.getNext(context);
assertEquals("Context rank", 1002, context.getRank());
// Position trace at event rank 4500 (TS = 4501)
- context = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE));
+ context = fExperiment.seekEvent(TmfTimestamp.create(4501, SCALE));
assertEquals("Context rank", 4500, context.getRank());
event = fExperiment.getNext(context);
@Test
public void testSeekTimestampOutOfScope() {
// Position trace at beginning
- ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(-1, SCALE));
+ ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(-1, SCALE));
assertEquals("Event rank", 0, context.getRank());
ITmfEvent event = fExperiment.getNext(context);
assertEquals("Event rank", 1, context.getRank());
// Position trace at event passed the end
- context = fExperiment.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE));
+ context = fExperiment.seekEvent(TmfTimestamp.create(NB_EVENTS + 1, SCALE));
event = fExperiment.getNext(context);
assertNull("Event location", event);
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
final int NB_READS = 20;
// On lower bound, returns the first event (ts = 1)
- final ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE));
+ final ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(INITIAL_TS, SCALE));
validateContextRanks(context);
final int NB_READS = 20;
// On lower bound, returns the first event (ts = 2)
- final ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE));
+ final ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(INITIAL_TS, SCALE));
validateContextRanks(context);
final int NB_READS = 20;
// On lower bound, returns the first event (ts = 500)
- final ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE));
+ final ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(INITIAL_TS, SCALE));
validateContextRanks(context);
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest;
-import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest;
import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest.ExecutionType;
+import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest;
import org.eclipse.tracecompass.tmf.core.tests.TmfCoreTestPlugin;
import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestTrace;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
assertEquals("getStartTime", 1, timeRange.getStartTime().getValue());
assertEquals("getEndTime", NB_EVENTS, timeRange.getEndTime().getValue());
- TmfTimestamp initRange = new TmfTimestamp(DEFAULT_INITIAL_OFFSET_VALUE, ITmfTimestamp.NANOSECOND_SCALE);
+ ITmfTimestamp initRange = TmfTimestamp.fromNanos(DEFAULT_INITIAL_OFFSET_VALUE);
assertEquals("getInitialRangeOffset", initRange, fExperiment.getInitialRangeOffset());
}
long cacheSize = fExperiment.getCacheSize();
// Position trace at event rank 0
- ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(1, SCALE));
+ ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(1, SCALE));
assertEquals("Context rank", 0, context.getRank());
ITmfEvent event = fExperiment.getNext(context);
assertEquals("Context rank", 1, context.getRank());
// Position trace at event rank [cacheSize]
- context = fExperiment.seekEvent(new TmfTimestamp(cacheSize + 1, SCALE));
+ context = fExperiment.seekEvent(TmfTimestamp.create(cacheSize + 1, SCALE));
assertEquals("Event rank", cacheSize, context.getRank());
event = fExperiment.getNext(context);
assertEquals("Context rank", cacheSize + 1, context.getRank());
// Position trace at event rank [4 * cacheSize]
- context = fExperiment.seekEvent(new TmfTimestamp(4 * cacheSize + 1, SCALE));
+ context = fExperiment.seekEvent(TmfTimestamp.create(4 * cacheSize + 1, SCALE));
assertEquals("Context rank", 4 * cacheSize, context.getRank());
event = fExperiment.getNext(context);
@Test
public void testSeekTimestampNotOnCacheBoundary() {
// Position trace at event rank 1 (TS = 2)
- ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(2, SCALE));
+ ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(2, SCALE));
assertEquals("Context rank", 1, context.getRank());
ITmfEvent event = fExperiment.getNext(context);
assertEquals("Context rank", 2, context.getRank());
// Position trace at event rank 9 (TS = 10)
- context = fExperiment.seekEvent(new TmfTimestamp(10, SCALE));
+ context = fExperiment.seekEvent(TmfTimestamp.create(10, SCALE));
assertEquals("Context rank", 9, context.getRank());
event = fExperiment.getNext(context);
assertEquals("Context rank", 10, context.getRank());
// Position trace at event rank 999 (TS = 1000)
- context = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE));
+ context = fExperiment.seekEvent(TmfTimestamp.create(1000, SCALE));
assertEquals("Context rank", 999, context.getRank());
event = fExperiment.getNext(context);
assertEquals("Context rank", 1000, context.getRank());
// Position trace at event rank 1001 (TS = 1002)
- context = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE));
+ context = fExperiment.seekEvent(TmfTimestamp.create(1002, SCALE));
assertEquals("Context rank", 1001, context.getRank());
event = fExperiment.getNext(context);
assertEquals("Context rank", 1002, context.getRank());
// Position trace at event rank 4500 (TS = 4501)
- context = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE));
+ context = fExperiment.seekEvent(TmfTimestamp.create(4501, SCALE));
assertEquals("Context rank", 4500, context.getRank());
event = fExperiment.getNext(context);
@Test
public void testSeekTimestampOutOfScope() {
// Position trace at beginning
- ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(-1, SCALE));
+ ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(-1, SCALE));
assertEquals("Event rank", 0, context.getRank());
ITmfEvent event = fExperiment.getNext(context);
assertEquals("Event rank", 1, context.getRank());
// Position trace at event passed the end
- context = fExperiment.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE));
+ context = fExperiment.seekEvent(TmfTimestamp.create(NB_EVENTS + 1, SCALE));
event = fExperiment.getNext(context);
assertNull("Event location", event);
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
final int NB_READS = 20;
// On lower bound, returns the first event (ts = 1)
- final ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE));
+ final ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(INITIAL_TS, SCALE));
validateContextRanks(context);
final int NB_READS = 20;
// On lower bound, returns the first event (ts = 2)
- final ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE));
+ final ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(INITIAL_TS, SCALE));
validateContextRanks(context);
final int NB_READS = 20;
// On lower bound, returns the first event (ts = 500)
- final ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE));
+ final ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(INITIAL_TS, SCALE));
validateContextRanks(context);
@Test
public void testGetTimestamp() {
- assertEquals("getTimestamp", new TmfTimestamp( 1, (byte) -3), fExperiment.getTimestamp( 0));
- assertEquals("getTimestamp", new TmfTimestamp( 2, (byte) -3), fExperiment.getTimestamp( 1));
- assertEquals("getTimestamp", new TmfTimestamp( 11, (byte) -3), fExperiment.getTimestamp( 10));
- assertEquals("getTimestamp", new TmfTimestamp( 101, (byte) -3), fExperiment.getTimestamp( 100));
- assertEquals("getTimestamp", new TmfTimestamp( 1001, (byte) -3), fExperiment.getTimestamp( 1000));
- assertEquals("getTimestamp", new TmfTimestamp( 2001, (byte) -3), fExperiment.getTimestamp( 2000));
- assertEquals("getTimestamp", new TmfTimestamp( 2501, (byte) -3), fExperiment.getTimestamp( 2500));
- assertEquals("getTimestamp", new TmfTimestamp(10000, (byte) -3), fExperiment.getTimestamp( 9999));
- assertEquals("getTimestamp", new TmfTimestamp(20000, (byte) -3), fExperiment.getTimestamp(19999));
+ assertEquals("getTimestamp", TmfTimestamp.create( 1, (byte) -3), fExperiment.getTimestamp( 0));
+ assertEquals("getTimestamp", TmfTimestamp.create( 2, (byte) -3), fExperiment.getTimestamp( 1));
+ assertEquals("getTimestamp", TmfTimestamp.create( 11, (byte) -3), fExperiment.getTimestamp( 10));
+ assertEquals("getTimestamp", TmfTimestamp.create( 101, (byte) -3), fExperiment.getTimestamp( 100));
+ assertEquals("getTimestamp", TmfTimestamp.create( 1001, (byte) -3), fExperiment.getTimestamp( 1000));
+ assertEquals("getTimestamp", TmfTimestamp.create( 2001, (byte) -3), fExperiment.getTimestamp( 2000));
+ assertEquals("getTimestamp", TmfTimestamp.create( 2501, (byte) -3), fExperiment.getTimestamp( 2500));
+ assertEquals("getTimestamp", TmfTimestamp.create(10000, (byte) -3), fExperiment.getTimestamp( 9999));
+ assertEquals("getTimestamp", TmfTimestamp.create(20000, (byte) -3), fExperiment.getTimestamp(19999));
assertNull("getTimestamp", fExperiment.getTimestamp(20000));
}
TmfExperimentStub exp = new TmfExperimentStub(EXPERIMENT, traces, BLOCK_SIZE);
// verify initial values
- TmfTimestamp initRange = new TmfTimestamp(DEFAULT_INITIAL_OFFSET_VALUE, ITmfTimestamp.NANOSECOND_SCALE);
+ ITmfTimestamp initRange = TmfTimestamp.fromNanos(DEFAULT_INITIAL_OFFSET_VALUE);
assertEquals("getInitialRangeOffset", initRange, exp.getInitialRangeOffset());
exp.dispose();
@Test
public void testInitialRangeOffset() {
ITmfTrace[] traces = setupTraces();
- ((TmfTraceStub) traces[0]).setInitialRangeOffset(new TmfTimestamp(5, ITmfTimestamp.MILLISECOND_SCALE));
- ((TmfTraceStub) traces[1]).setInitialRangeOffset(new TmfTimestamp(2, ITmfTimestamp.MILLISECOND_SCALE));
+ ((TmfTraceStub) traces[0]).setInitialRangeOffset(TmfTimestamp.fromMillis(5));
+ ((TmfTraceStub) traces[1]).setInitialRangeOffset(TmfTimestamp.fromMillis(2));
TmfExperimentStub exp = new TmfExperimentStub(EXPERIMENT, traces, BLOCK_SIZE);
- TmfTimestamp initRange = new TmfTimestamp(2, ITmfTimestamp.MILLISECOND_SCALE);
+ ITmfTimestamp initRange = TmfTimestamp.fromMillis(2);
assertEquals("getInitialRangeOffset", initRange, exp.getInitialRangeOffset());
exp.dispose();
assertEquals("getStartTime", 1, trace.getStartTime().getValue());
assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue());
- trace.setTimeRange(new TmfTimeRange(new TmfTimestamp(100), new TmfTimestamp(200)));
+ trace.setTimeRange(new TmfTimeRange(TmfTimestamp.fromSeconds(100), TmfTimestamp.fromSeconds(200)));
assertEquals("setTimeRange", 100, trace.getTimeRange().getStartTime().getValue());
assertEquals("setTimeRange", 200, trace.getTimeRange().getEndTime().getValue());
assertEquals("setTimeRange", 100, trace.getStartTime().getValue());
assertEquals("getStartTime", 1, trace.getStartTime().getValue());
assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue());
- trace.setStartTime(new TmfTimestamp(100));
+ trace.setStartTime(TmfTimestamp.fromSeconds(100));
assertEquals("setStartTime", 100, trace.getTimeRange().getStartTime().getValue());
assertEquals("setStartTime", NB_EVENTS, trace.getTimeRange().getEndTime().getValue());
assertEquals("setStartTime", 100, trace.getStartTime().getValue());
assertEquals("getStartTime", 1, trace.getStartTime().getValue());
assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue());
- trace.setEndTime(new TmfTimestamp(100));
+ trace.setEndTime(TmfTimestamp.fromSeconds(100));
assertEquals("setEndTime", 1, trace.getTimeRange().getStartTime().getValue());
assertEquals("setEndTime", 100, trace.getTimeRange().getEndTime().getValue());
assertEquals("setEndTime", 1, trace.getStartTime().getValue());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
// Position trace at event rank 1000
- ITmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(1001, SCALE));
+ ITmfContext tmpContext = fTrace.seekEvent(TmfTimestamp.create(1001, SCALE));
context = fTrace.seekEvent(tmpContext.getLocation());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
// Position trace at event rank 4000
- tmpContext = fTrace.seekEvent(new TmfTimestamp(4001, SCALE));
+ tmpContext = fTrace.seekEvent(TmfTimestamp.create(4001, SCALE));
context = fTrace.seekEvent(tmpContext.getLocation());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
@Test
public void testSeekEventNotOnCacheBoundary() {
// Position trace at event rank 9
- ITmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(10, SCALE));
+ ITmfContext tmpContext = fTrace.seekEvent(TmfTimestamp.create(10, SCALE));
TmfContext context = fTrace.seekEvent(tmpContext.getLocation());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
// Position trace at event rank 999
- tmpContext = fTrace.seekEvent(new TmfTimestamp(1000, SCALE));
+ tmpContext = fTrace.seekEvent(TmfTimestamp.create(1000, SCALE));
context = fTrace.seekEvent(tmpContext.getLocation());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
// Position trace at event rank 1001
- tmpContext = fTrace.seekEvent(new TmfTimestamp(1002, SCALE));
+ tmpContext = fTrace.seekEvent(TmfTimestamp.create(1002, SCALE));
context = fTrace.seekEvent(tmpContext.getLocation());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
// Position trace at event rank 4500
- tmpContext = fTrace.seekEvent(new TmfTimestamp(4501, SCALE));
+ tmpContext = fTrace.seekEvent(TmfTimestamp.create(4501, SCALE));
context = fTrace.seekEvent(tmpContext.getLocation());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
// Position trace at event passed the end
- context = fTrace.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE));
+ context = fTrace.seekEvent(TmfTimestamp.create(NB_EVENTS + 1, SCALE));
assertNull("Event timestamp", context.getLocation());
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
@Test
public void testSeekEventOnTimestampOnCacheBoundary() {
// Position trace at event rank 0
- ITmfContext context = fTrace.seekEvent(new TmfTimestamp(1, SCALE));
+ ITmfContext context = fTrace.seekEvent(TmfTimestamp.create(1, SCALE));
assertEquals("Event rank", 0, context.getRank());
ITmfEvent event = fTrace.parseEvent(context);
assertEquals("Event rank", 1, context.getRank());
// Position trace at event rank 1000
- context = fTrace.seekEvent(new TmfTimestamp(1001, SCALE));
+ context = fTrace.seekEvent(TmfTimestamp.create(1001, SCALE));
assertEquals("Event rank", 1000, context.getRank());
event = fTrace.parseEvent(context);
assertEquals("Event rank", 1001, context.getRank());
// Position trace at event rank 4000
- context = fTrace.seekEvent(new TmfTimestamp(4001, SCALE));
+ context = fTrace.seekEvent(TmfTimestamp.create(4001, SCALE));
assertEquals("Event rank", 4000, context.getRank());
event = fTrace.parseEvent(context);
@Test
public void testSeekEventOnTimestampNotOnCacheBoundary() {
// Position trace at event rank 1
- ITmfContext context = fTrace.seekEvent(new TmfTimestamp(2, SCALE));
+ ITmfContext context = fTrace.seekEvent(TmfTimestamp.create(2, SCALE));
assertEquals("Event rank", 1, context.getRank());
ITmfEvent event = fTrace.parseEvent(context);
assertEquals("Event rank", 2, context.getRank());
// Position trace at event rank 9
- context = fTrace.seekEvent(new TmfTimestamp(10, SCALE));
+ context = fTrace.seekEvent(TmfTimestamp.create(10, SCALE));
assertEquals("Event rank", 9, context.getRank());
event = fTrace.parseEvent(context);
assertEquals("Event rank", 10, context.getRank());
// Position trace at event rank 999
- context = fTrace.seekEvent(new TmfTimestamp(1000, SCALE));
+ context = fTrace.seekEvent(TmfTimestamp.create(1000, SCALE));
assertEquals("Event rank", 999, context.getRank());
event = fTrace.parseEvent(context);
assertEquals("Event rank", 1000, context.getRank());
// Position trace at event rank 1001
- context = fTrace.seekEvent(new TmfTimestamp(1002, SCALE));
+ context = fTrace.seekEvent(TmfTimestamp.create(1002, SCALE));
assertEquals("Event rank", 1001, context.getRank());
event = fTrace.parseEvent(context);
assertEquals("Event rank", 1002, context.getRank());
// Position trace at event rank 4500
- context = fTrace.seekEvent(new TmfTimestamp(4501, SCALE));
+ context = fTrace.seekEvent(TmfTimestamp.create(4501, SCALE));
assertEquals("Event rank", 4500, context.getRank());
event = fTrace.parseEvent(context);
@Test
public void testSeekEventOnTimestampOutOfScope() {
// Position trace at beginning
- ITmfContext context = fTrace.seekEvent(new TmfTimestamp(-1, SCALE));
+ ITmfContext context = fTrace.seekEvent(TmfTimestamp.create(-1, SCALE));
assertEquals("Event rank", 0, context.getRank());
ITmfEvent event = fTrace.parseEvent(context);
assertEquals("Event rank", 1, context.getRank());
// Position trace at event passed the end
- context = fTrace.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE));
+ context = fTrace.seekEvent(TmfTimestamp.create(NB_EVENTS + 1, SCALE));
assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
event = fTrace.parseEvent(context);
final int NB_READS = 20;
// On lower bound, returns the first event (ts = 0)
- final TmfContext context = (TmfContext) fTrace.seekEvent(new TmfTimestamp(0, SCALE));
+ final TmfContext context = (TmfContext) fTrace.seekEvent(TmfTimestamp.create(0, SCALE));
TmfContext svContext = new TmfContext(context);
ITmfEvent event = fTrace.parseEvent(context);
final int NB_READS = 20;
// On lower bound, returns the first event (ts = 1)
- final ITmfContext context = fTrace.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE));
+ final ITmfContext context = fTrace.seekEvent(TmfTimestamp.create(INITIAL_TS, SCALE));
// Read NB_EVENTS
ITmfEvent event;
final int NB_READS = 20;
// On lower bound, returns the first event (ts = 500)
- final ITmfContext context = fTrace.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE));
+ final ITmfContext context = fTrace.seekEvent(TmfTimestamp.create(INITIAL_TS, SCALE));
// Read NB_EVENTS
ITmfEvent event;
final int NB_READS = 20;
// On lower bound, returns the first event (ts = 500)
- final ITmfContext context = fTrace.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE));
+ final ITmfContext context = fTrace.seekEvent(TmfTimestamp.create(INITIAL_TS, SCALE));
// Read NB_EVENTS
ITmfEvent event;
final int nbEvents = 1000;
final Vector<ITmfEvent> requestedEvents = new Vector<>();
- final TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(startTime, SCALE), TmfTimestamp.BIG_CRUNCH);
+ final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.create(startTime, SCALE), TmfTimestamp.BIG_CRUNCH);
final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
range, 0, nbEvents, ExecutionType.FOREGROUND) {
@Override
final int nbEvents = 1000;
final Vector<ITmfEvent> requestedEvents = new Vector<>();
- final TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(startTime, SCALE), TmfTimestamp.BIG_CRUNCH);
+ final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.create(startTime, SCALE), TmfTimestamp.BIG_CRUNCH);
final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
range, startIndex, nbEvents, ExecutionType.FOREGROUND) {
@Override
testfile = new File(FileLocator.toFileURL(location).toURI());
trace = new TmfTraceStub(testfile.toURI().getPath(), ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, false, null);
// verify initial values
- TmfTimestamp defaultInitRange = new TmfTimestamp(DEFAULT_INITIAL_OFFSET_VALUE, ITmfTimestamp.NANOSECOND_SCALE);
+ ITmfTimestamp defaultInitRange = TmfTimestamp.fromNanos(DEFAULT_INITIAL_OFFSET_VALUE);
assertEquals("getInitialRangeOffset", defaultInitRange, trace.getInitialRangeOffset());
- trace.setInitialRangeOffset(new TmfTimestamp(5, ITmfTimestamp.MILLISECOND_SCALE));
+ trace.setInitialRangeOffset(TmfTimestamp.fromMillis(5));
trace.indexTrace(true);
- TmfTimestamp initRange = new TmfTimestamp(5, ITmfTimestamp.MILLISECOND_SCALE);
+ ITmfTimestamp initRange = TmfTimestamp.fromMillis(5);
assertEquals("getInitialRangeOffset", initRange, trace.getInitialRangeOffset());
trace.dispose();
@Test
public void testSetGetTimeRange() {
if (isPersistableCollection()) {
- TmfTimeRange timeRange = new TmfTimeRange(new TmfTimestamp(0), new TmfTimestamp(100));
+ TmfTimeRange timeRange = new TmfTimeRange(TmfTimestamp.fromSeconds(0), TmfTimestamp.fromSeconds(100));
fCheckpointCollection.setTimeRange(timeRange);
assertEquals(timeRange, fCheckpointCollection.getTimeRange());
}
assertEquals(0, fCheckpointCollection.size());
int expected = CHECKPOINTS_INSERT_NUM;
for (int i = 0; i < expected; ++i) {
- fCheckpointCollection.insert(new TmfCheckpoint(new TmfTimestamp(i), new TmfLongLocation(i), i));
+ fCheckpointCollection.insert(new TmfCheckpoint(TmfTimestamp.fromSeconds(i), new TmfLongLocation(i), i));
}
assertEquals(expected, fCheckpointCollection.size());
}
*/
@Test
public void testInsert() {
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345), new TmfLongLocation(123456L), 0);
+ TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345), new TmfLongLocation(123456L), 0);
fCheckpointCollection.insert(checkpoint);
long found = fCheckpointCollection.binarySearch(checkpoint);
*/
protected ArrayList<Integer> insertAlot() {
for (int i = 0; i < CHECKPOINTS_INSERT_NUM; i++) {
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345 + i), new TmfLongLocation(123456L + i), i);
+ TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345 + i), new TmfLongLocation(123456L + i), i);
fCheckpointCollection.insert(checkpoint);
}
for (int i = 0; i < CHECKPOINTS_INSERT_NUM; i++) {
Integer randomCheckpoint = list.get(i);
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345 + randomCheckpoint), new TmfLongLocation(123456L + randomCheckpoint), 0);
+ TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345 + randomCheckpoint), new TmfLongLocation(123456L + randomCheckpoint), 0);
long found = fCheckpointCollection.binarySearch(checkpoint);
assertEquals(randomCheckpoint.intValue(), found);
}
@Test
public void testInsertSameTimestamp() {
for (int i = 0; i < CHECKPOINTS_INSERT_NUM; i++) {
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345), new TmfLongLocation(123456L + i), i);
+ TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345), new TmfLongLocation(123456L + i), i);
fCheckpointCollection.insert(checkpoint);
}
assertEquals(CHECKPOINTS_INSERT_NUM, fCheckpointCollection.size());
for (int i = 0; i < CHECKPOINTS_INSERT_NUM; i++) {
Integer randomCheckpoint = list.get(i);
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345), new TmfLongLocation(123456L + randomCheckpoint), 0);
+ TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345), new TmfLongLocation(123456L + randomCheckpoint), 0);
long found = fCheckpointCollection.binarySearch(checkpoint);
assertEquals(randomCheckpoint.intValue(), found);
}
@Test
public void testBinarySearchFindInBetween() {
for (long i = 0; i < CHECKPOINTS_INSERT_NUM; i++) {
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(2 * i), new TmfLongLocation(2 * i), i);
+ TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(2 * i), new TmfLongLocation(2 * i), i);
fCheckpointCollection.insert(checkpoint);
}
assertEquals(CHECKPOINTS_INSERT_NUM, fCheckpointCollection.size());
- TmfCheckpoint searchedCheckpoint = new TmfCheckpoint(new TmfTimestamp(123), new TmfLongLocation(123L), 123);
+ TmfCheckpoint searchedCheckpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(123), new TmfLongLocation(123L), 123);
int expectedInsertionPoint = 61;
int expectedRank = -(expectedInsertionPoint + 2);
public void testBinarySearchInBetweenSameTimestamp() {
int checkpointNum = 0;
for (; checkpointNum < CHECKPOINTS_INSERT_NUM / 2; checkpointNum++) {
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(0), new TmfLongLocation(checkpointNum), checkpointNum);
+ TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(0), new TmfLongLocation(checkpointNum), checkpointNum);
fCheckpointCollection.insert(checkpoint);
}
for (; checkpointNum < CHECKPOINTS_INSERT_NUM; checkpointNum++) {
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(1), new TmfLongLocation(checkpointNum), checkpointNum);
+ TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(1), new TmfLongLocation(checkpointNum), checkpointNum);
fCheckpointCollection.insert(checkpoint);
}
assertEquals(CHECKPOINTS_INSERT_NUM, fCheckpointCollection.size());
- final TmfCheckpoint searchedCheckpoint = new TmfCheckpoint(new TmfTimestamp(1), null, 0);
+ final TmfCheckpoint searchedCheckpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(1), null, 0);
long found = fCheckpointCollection.binarySearch(searchedCheckpoint);
return;
}
- fCheckpointCollection.insert(new TmfCheckpoint(new TmfTimestamp(12345), new TmfLongLocation(123456L), 0));
+ fCheckpointCollection.insert(new TmfCheckpoint(TmfTimestamp.fromSeconds(12345), new TmfLongLocation(123456L), 0));
assertEquals(1, fCheckpointCollection.size());
fCheckpointCollection = createCollection();
assertEquals(1, fCheckpointCollection.size());
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345), new TmfLongLocation(123456L), 0);
+ TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345), new TmfLongLocation(123456L), 0);
long found = fCheckpointCollection.binarySearch(checkpoint);
assertEquals(0, found);
- fCheckpointCollection.insert(new TmfCheckpoint(new TmfTimestamp(12345 + 1), new TmfLongLocation(123456L + 1), 1));
+ fCheckpointCollection.insert(new TmfCheckpoint(TmfTimestamp.fromSeconds(12345 + 1), new TmfLongLocation(123456L + 1), 1));
assertEquals(2, fCheckpointCollection.size());
fCheckpointCollection.dispose();
public void testInsertAfterEmptyReopen() {
fCheckpointCollection.dispose();
fCheckpointCollection = createCollection();
- fCheckpointCollection.insert(new TmfCheckpoint(new TmfTimestamp(12345), new TmfLongLocation(123456L), 0));
+ fCheckpointCollection.insert(new TmfCheckpoint(TmfTimestamp.fromSeconds(12345), new TmfLongLocation(123456L), 0));
assertEquals(1, fCheckpointCollection.size());
}
}
long old = System.currentTimeMillis();
bTree = new BTree(BTREE_DEGREE, file, fTrace);
for (int i = 0; i < checkpointsNum; i++) {
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345 + i), new TmfLongLocation(123456L + i), i);
+ TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345 + i), new TmfLongLocation(123456L + i), i);
bTree.insert(checkpoint);
}
long old = System.currentTimeMillis();
array = new FlatArray(file, fTrace);
for (int i = 0; i < checkpointsNum; i++) {
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345 + i), new TmfLongLocation(123456L + i), i);
+ TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345 + i), new TmfLongLocation(123456L + i), i);
array.insert(checkpoint);
}
bTree = new BTree(BTREE_DEGREE, file, fTrace);
for (int i = 0; i < checkpointsNum; i++) {
Integer randomCheckpoint = list.get(i);
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345 + randomCheckpoint), new TmfLongLocation(123456L + randomCheckpoint), 0);
+ TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345 + randomCheckpoint), new TmfLongLocation(123456L + randomCheckpoint), 0);
BTreeCheckpointVisitor treeVisitor = new BTreeCheckpointVisitor(checkpoint);
bTree.accept(treeVisitor);
assertEquals(randomCheckpoint.intValue(), treeVisitor.getCheckpoint().getCheckpointRank());
array = new FlatArray(file, fTrace);
for (int i = 0; i < checkpointsNum; i++) {
Integer randomCheckpoint = list.get(i);
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345 + randomCheckpoint), new TmfLongLocation(123456L + randomCheckpoint), 0);
+ TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345 + randomCheckpoint), new TmfLongLocation(123456L + randomCheckpoint), 0);
long found = array.binarySearch(checkpoint);
assertEquals(randomCheckpoint.intValue(), found);
}
@Test
public void testAccept() {
for (int i = 0; i < CHECKPOINTS_INSERT_NUM; i++) {
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(i), new TmfLongLocation(i), 0);
+ TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(i), new TmfLongLocation(i), 0);
fBTree.insert(checkpoint);
}
- final TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(123), new TmfLongLocation(123L), 0);
+ final TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(123), new TmfLongLocation(123L), 0);
class TestVisitor implements IBTreeVisitor {
public int fLastCompare = 0;
for (int i = 0; i < CHECKPOINTS_INSERT_NUM; i++) {
Integer checkpointIndex = list.get(i);
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345 + checkpointIndex), new TmfLongLocation(123456L + checkpointIndex), 0);
+ TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345 + checkpointIndex), new TmfLongLocation(123456L + checkpointIndex), 0);
BTreeCheckpointVisitor treeVisitor = new BTreeCheckpointVisitor(checkpoint);
fBTree.accept(treeVisitor);
assertEquals(checkpoint, treeVisitor.getCheckpoint());
@Test
public void testBinarySearch() {
for (long i = 0; i < CHECKPOINTS_INSERT_NUM; i++) {
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(i), new TmfLongLocation(i), 0);
+ TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(i), new TmfLongLocation(i), 0);
fFlatArray.insert(checkpoint);
}
- TmfCheckpoint expectedCheckpoint = new TmfCheckpoint(new TmfTimestamp(122), new TmfLongLocation(122L), 0);
+ TmfCheckpoint expectedCheckpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(122), new TmfLongLocation(122L), 0);
int expectedRank = 122;
long rank = fFlatArray.binarySearch(expectedCheckpoint);
for (int i = 0; i < CHECKPOINTS_INSERT_NUM; i++) {
int checkpointIndex = list.get(i);
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345 + checkpointIndex),
+ TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345 + checkpointIndex),
new TmfLongLocation(123456L + checkpointIndex), checkpointIndex);
ITmfCheckpoint found = fFlatArray.get(checkpointIndex);
assertEquals(checkpoint, found);
@Override
@Test
public void testInsert() {
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345), new TmfLongLocation(123456L), 0);
+ TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345), new TmfLongLocation(123456L), 0);
fMemoryIndex.insert(checkpoint);
ITmfCheckpoint indexCheckpoint = fMemoryIndex.get(0);
@Test
public void testBinarySearch() {
for (long i = 0; i < CHECKPOINTS_INSERT_NUM; i++) {
- TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(i), new TmfLongLocation(i), 0);
+ TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(i), new TmfLongLocation(i), 0);
fMemoryIndex.insert(checkpoint);
}
- TmfCheckpoint expectedCheckpoint = new TmfCheckpoint(new TmfTimestamp(122), new TmfLongLocation(122L), 0);
+ TmfCheckpoint expectedCheckpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(122), new TmfLongLocation(122L), 0);
int expectedRank = 122;
long rank = fMemoryIndex.binarySearch(expectedCheckpoint);
import org.eclipse.tracecompass.tmf.core.tests.TmfCoreTestPlugin;
import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestTrace;
import org.eclipse.tracecompass.tmf.core.tests.trace.indexer.checkpoint.AbstractIndexTest.ITestIndexer;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.core.trace.indexer.ITmfTraceIndexer;
// Verify that the event at rank=99 is returned when seeking to ts=101 (first event with this timestamp)
// and not the event at checkpoint boundary
- TmfTimestamp seekTs = new TmfTimestamp(101, -3);
+ ITmfTimestamp seekTs = TmfTimestamp.create(101, -3);
ITmfContext ctx = fTrace.seekEvent(seekTs);
ITmfEvent event = fTrace.getNext(ctx);
// Trace has events with same timestamp (ts=102) for ranks 102..702 -> 2 checkpoints with same timestamp are created
// Verify that the event at rank=102 is returned when seeking to ts=102 (first event with this timestamp)
// and not the event at checkpoint boundary
- seekTs = new TmfTimestamp(102, -3);
+ seekTs = TmfTimestamp.create(102, -3);
ctx = fTrace.seekEvent(seekTs);
event = fTrace.getNext(ctx);
assertEquals(0, seekTs.compareTo(event.getTimestamp()));
// Verify seek to first checkpoint
- seekTs = new TmfTimestamp(1, -3);
+ seekTs = TmfTimestamp.create(1, -3);
ctx = fTrace.seekEvent(seekTs);
event = fTrace.getNext(ctx);
assertEquals(0, seekTs.compareTo(event.getTimestamp()));
// Verify seek to timestamp before first event
- seekTs = new TmfTimestamp(0, -3);
+ seekTs = TmfTimestamp.create(0, -3);
ctx = fTrace.seekEvent(seekTs);
event = fTrace.getNext(ctx);
assertEquals(1, ctx.getRank());
- assertEquals(0, new TmfTimestamp(1, -3).compareTo(event.getTimestamp()));
+ assertEquals(0, TmfTimestamp.create(1, -3).compareTo(event.getTimestamp()));
// Verify seek to timestamp between first and second checkpoint
- seekTs = new TmfTimestamp(50, -3);
+ seekTs = TmfTimestamp.create(50, -3);
ctx = fTrace.seekEvent(seekTs);
event = fTrace.getNext(ctx);
assertEquals(0, seekTs.compareTo(event.getTimestamp()));
// Verify seek to timestamp after last event in trace
- seekTs = new TmfTimestamp(103, -3);
+ seekTs = TmfTimestamp.create(103, -3);
ctx = fTrace.seekEvent(seekTs);
event = fTrace.getNext(ctx);
// Variables
// ------------------------------------------------------------------------
- private ITmfTimestamp fTimestamp1 = new TmfTimestamp();
+ private ITmfTimestamp fTimestamp1 = TmfTimestamp.fromSeconds(0);
private ITmfTimestamp fTimestamp2 = TmfTimestamp.BIG_BANG;
private ITmfTimestamp fTimestamp3 = TmfTimestamp.BIG_CRUNCH;
assertFalse("equals", checkpoint1.equals(null));
// Different types
- assertFalse("equals", checkpoint1.equals(new TmfTimestamp()));
+ assertFalse("equals", checkpoint1.equals(TmfTimestamp.fromSeconds(0)));
// Null locations/location
assertFalse("equals", checkpoint1.equals(checkpoint4));
int pageSize = experiment.getCacheSize();
// Build the first half of the index
- TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(1, -3), new TmfTimestamp(NB_EVENTS / 2 - 1, -3));
+ TmfTimeRange range = new TmfTimeRange(TmfTimestamp.create(1, -3), TmfTimestamp.create(NB_EVENTS / 2 - 1, -3));
experiment.getIndexer().buildIndex(0, range, true);
// Validate that each checkpoint points to the right event
import org.eclipse.tracecompass.internal.tmf.core.trace.experiment.TmfExperimentLocation;
import org.eclipse.tracecompass.internal.tmf.core.trace.experiment.TmfLocationArray;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation;
import org.eclipse.tracecompass.tmf.core.trace.location.TmfLocation;
// ------------------------------------------------------------------------
private Long aLong = 12345L;
- private TmfTimestamp aTimestamp = new TmfTimestamp();
+ private ITmfTimestamp aTimestamp = TmfTimestamp.create(0, ITmfTimestamp.SECOND_SCALE);
private TmfLocationArray aLocationArray;
private TmfLongLocation fLocation1;
@Test
public void testToString() {
- TmfTimestamp ts = new TmfTimestamp();
+ ITmfTimestamp ts = TmfTimestamp.create(0, ITmfTimestamp.SECOND_SCALE);
TmfLongLocation location1 = new TmfLongLocation(aLong);
TmfTimestampLocation location2 = new TmfTimestampLocation(ts);
assertEquals("getName", "", trace.getName());
assertEquals("getCacheSize", 100, trace.getCacheSize());
- TmfTimestamp initRange = new TmfTimestamp(60, ITmfTimestamp.SECOND_SCALE);
+ ITmfTimestamp initRange = TmfTimestamp.fromSeconds(60);
assertEquals("getInitialRangeOffset", initRange, trace.getInitialRangeOffset());
}
public void testTraceIndexing() {
assertEquals("getNbEvents", 6, fTrace.getNbEvents());
- TmfTimestamp initRange = new TmfTimestamp(60, ITmfTimestamp.SECOND_SCALE);
+ ITmfTimestamp initRange = TmfTimestamp.fromSeconds(60);
assertEquals("getInitialRangeOffset", initRange, fTrace.getInitialRangeOffset());
}
import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.core.uml2sd.TmfAsyncSequenceDiagramEvent;
private final String fLabel1 = "label2";
private final String[] fLabels = new String[] { fLabel0, fLabel1 };
- private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2);
- private final TmfTimestamp fTimestamp2 = new TmfTimestamp(12350, (byte) 2);
+ private final ITmfTimestamp fTimestamp1 = TmfTimestamp.create(12345, (byte) 2);
+ private final ITmfTimestamp fTimestamp2 = TmfTimestamp.create(12350, (byte) 2);
private final TmfEventType fType = new TmfEventType(fTypeId, TmfEventField.makeRoot(fLabels));
private final ITmfEvent fEvent1;
import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.core.uml2sd.TmfSyncSequenceDiagramEvent;
private final @NonNull String fLabel1 = "label2";
private final String[] fLabels = new String[] { fLabel0, fLabel1 };
- private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2);
+ private final ITmfTimestamp fTimestamp1 = TmfTimestamp.create(12345, (byte) 2);
private final TmfEventType fType = new TmfEventType(fTypeId, TmfEventField.makeRoot(fLabels));
private final ITmfEvent fEvent1;
import org.eclipse.tracecompass.tmf.core.component.TmfEventProvider;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest;
-import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest;
import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest.ExecutionType;
+import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.core.trace.TmfContext;
@Override
public ITmfTimestamp createTimestamp(long ts) {
- return new TmfTimestamp(getTimestampTransform().transform(ts) / 1000000L, ITmfTimestamp.MILLISECOND_SCALE);
+ return TmfTimestamp.fromMillis(getTimestampTransform().transform(ts) / 1000000L);
}
@Override
@Override
public synchronized int getCheckpointSize() {
if (fCheckpointSize == -1) {
- TmfCheckpoint c = new TmfCheckpoint(new TmfTimestamp(0L), new TmfLongLocation(0L), 0);
+ TmfCheckpoint c = new TmfCheckpoint(TmfTimestamp.fromSeconds(0L), new TmfLongLocation(0L), 0);
ByteBuffer b = ByteBuffer.allocate(ITmfCheckpoint.MAX_SERIALIZE_SIZE);
b.clear();
c.serialize(b);
timestamp = createTimestamp(ns);
}
} catch (ParseException e) {
- timestamp = new TmfTimestamp();
+ timestamp = TmfTimestamp.create(0, ITmfTimestamp.SECOND_SCALE);
}
TextTraceEventContent content = new TextTraceEventContent(5);
@Override
public ITmfTimestamp getInitialRangeOffset() {
- return new TmfTimestamp(60, ITmfTimestamp.SECOND_SCALE);
+ return TmfTimestamp.fromSeconds(60);
}
@Override
import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTraceDefinition;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.core.trace.TmfContext;
import org.eclipse.tracecompass.tmf.core.trace.TmfTrace;
* original is in second and we need to convert it. We should do that at
* the source when it is supported
*/
- ITmfTimestamp timestamp = new TmfNanoTimestamp(event.getTimestamp().getValue() / SECONDS_TO_NS);
+ ITmfTimestamp timestamp = TmfTimestamp.fromNanos(event.getTimestamp().getValue() / SECONDS_TO_NS);
TmfEvent newEvent = new TmfEvent(this, ITmfContext.UNKNOWN_RANK, timestamp, eventType, eventFields);
updateAttributes(savedContext, event);
return newEvent;
import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest;
import org.eclipse.tracecompass.tmf.core.statesystem.AbstractTmfStateProvider;
import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
-import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
* caused by the event(s) happening exactly at 'checkpointTime',
* if any. We must not include those events in the query.
*/
- new TmfTimestamp(checkpointTime + 1, ITmfTimestamp.NANOSECOND_SCALE),
- new TmfTimestamp(t, ITmfTimestamp.NANOSECOND_SCALE));
+ TmfTimestamp.fromNanos(checkpointTime + 1),
+ TmfTimestamp.fromNanos(t));
ITmfEventRequest request = new PartialStateSystemRequest(fPartialInput, range);
fPartialInput.getTrace().sendRequest(request);
import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException;
import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
-import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue.Type;
+import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
/**
* The average mipmap feature.
import org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform;
import org.eclipse.tracecompass.tmf.core.synchronization.TimestampTransformFactory;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
/**
* Constant transform, just offset your timestamp with another.
* The offset of the linear transform
*/
public TmfConstantTransform(@NonNull ITmfTimestamp offset) {
- this(new TmfNanoTimestamp(offset).getValue());
+ this(offset.toNanos());
}
@Override
@Override
public ITmfTimestamp transform(ITmfTimestamp timestamp) {
BigDecimal newvalue = BigDecimal.valueOf(timestamp.getValue()).multiply(fAlpha, fMc).add(fBeta);
- return new TmfTimestamp(timestamp, newvalue.longValue());
+ return TmfTimestamp.create(newvalue.longValue(), timestamp.getScale());
}
@Override
@Override
public ITmfTimestamp transform(ITmfTimestamp timestamp) {
- return new TmfTimestamp(timestamp, transform(timestamp.getValue()));
+ return TmfTimestamp.create(transform(timestamp.getValue()), timestamp.getScale());
}
@Override
b.clear();
fFileChannel.read(b);
b.flip();
- fTimeRange = new TmfTimeRange(new TmfTimestamp(b), new TmfTimestamp(b));
+ fTimeRange = new TmfTimeRange(TmfTimestamp.create(b), TmfTimestamp.create(b));
}
/**
ByteBuffer b = ByteBuffer.allocate(MAX_TIME_RANGE_SERIALIZE_SIZE);
b.clear();
- new TmfTimestamp(fTimeRange.getStartTime()).serialize(b);
- new TmfTimestamp(fTimeRange.getEndTime()).serialize(b);
+ TmfTimestamp.serialize(b, fTimeRange.getStartTime());
+ TmfTimestamp.serialize(b, fTimeRange.getEndTime());
b.rewind();
fFileChannel.write(b);
}
for (int i = 0; i < fNumEntries; ++i) {
ITmfLocation location = fTree.getTrace().restoreLocation(bb);
- ITmfTimestamp timeStamp = new TmfTimestamp(bb);
+ ITmfTimestamp timeStamp = TmfTimestamp.create(bb);
TmfCheckpoint c = new TmfCheckpoint(timeStamp, location, bb);
fEntries[i] = c;
}
fByteBuffer.clear();
getRandomAccessFile().read(fByteBuffer.array());
ITmfLocation location = getTrace().restoreLocation(fByteBuffer);
- ITmfTimestamp timeStamp = new TmfTimestamp(fByteBuffer);
+ ITmfTimestamp timeStamp = TmfTimestamp.create(fByteBuffer);
checkpoint = new TmfCheckpoint(timeStamp, location, fByteBuffer);
} catch (IOException e) {
Activator.logError(MessageFormat.format(Messages.FlatArray_IOErrorReading, getFile()), e);
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
/**
return (ITmfTimestamp) value;
}
try {
- return new TmfNanoTimestamp(fTimestampFormat.parseValue(value.toString()));
+ return TmfTimestamp.fromNanos(fTimestampFormat.parseValue(value.toString()));
} catch (ParseException e) {
}
return null;
import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTraceDefinition.OutputColumn;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
private void processData() {
String timestampString = fData.get(CustomTraceDefinition.TAG_TIMESTAMP);
String timestampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);
- TmfTimestamp timestamp = null;
+ ITmfTimestamp timestamp = null;
if (timestampInputFormat != null && timestampString != null) {
TmfTimestampFormat timestampFormat = new TmfTimestampFormat(timestampInputFormat);
try {
long time = timestampFormat.parseValue(timestampString);
- timestamp = new TmfNanoTimestamp(getTrace().getTimestampTransform().transform(time));
+ timestamp = TmfTimestamp.fromNanos(getTrace().getTimestampTransform().transform(time));
setTimestamp(timestamp);
} catch (ParseException e) {
setTimestamp(TmfTimestamp.ZERO);
@Override
public long getEventsInRange(long start, long end) {
- ITmfTimestamp startTS = new TmfTimestamp(start, SCALE);
- ITmfTimestamp endTS = new TmfTimestamp(end, SCALE);
+ ITmfTimestamp startTS = TmfTimestamp.create(start, SCALE);
+ ITmfTimestamp endTS = TmfTimestamp.create(end, SCALE);
TmfTimeRange range = new TmfTimeRange(startTS, endTS);
StatsTotalRequest request = new StatsTotalRequest(trace, range);
@Override
public Map<String, Long> getEventTypesInRange(long start, long end) {
- ITmfTimestamp startTS = new TmfTimestamp(start, SCALE);
- ITmfTimestamp endTS = new TmfTimestamp(end, SCALE);
+ ITmfTimestamp startTS = TmfTimestamp.create(start, SCALE);
+ ITmfTimestamp endTS = TmfTimestamp.create(end, SCALE);
TmfTimeRange range = new TmfTimeRange(startTS, endTS);
StatsPerTypeRequest request = new StatsPerTypeRequest(trace, range);
public HistogramQueryRequest(long[] borders, long endTime) {
super(trace.getEventType(),
new TmfTimeRange(
- new TmfTimestamp(borders[0], SCALE),
- new TmfTimestamp(endTime, SCALE)),
+ TmfTimestamp.create(borders[0], SCALE),
+ TmfTimestamp.create(endTime, SCALE)),
0,
ITmfEventRequest.ALL_DATA,
ITmfEventRequest.ExecutionType.BACKGROUND);
/**
* A simplified timestamp where scale is nanoseconds and precision is set to 0.
*/
-public class TmfNanoTimestamp extends TmfTimestamp {
+public final class TmfNanoTimestamp extends TmfTimestamp {
+
+ private final long fValue;
// ------------------------------------------------------------------------
// Constructors
* the timestamp value
*/
public TmfNanoTimestamp(final long value) {
- super(value, ITmfTimestamp.NANOSECOND_SCALE);
+ fValue = value;
}
- /**
- * Copy constructor.
- *
- * If the parameter is not a TmfNanoTimestamp, the timestamp will be scaled
- * to nanoseconds, and the precision will be discarded.
- *
- * @param timestamp
- * The timestamp to copy
- */
- public TmfNanoTimestamp(final ITmfTimestamp timestamp) {
- super(timestamp.toNanos(), ITmfTimestamp.NANOSECOND_SCALE);
+ @Override
+ public long getValue() {
+ return fValue;
+ }
+
+
+ @Override
+ public int getScale() {
+ return ITmfTimestamp.NANOSECOND_SCALE;
}
// ------------------------------------------------------------------------
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.tmf.core.timestamp;
+
+/**
+ * A timestamp with a user provided scale and value
+ *
+ * @author Matthew Khouzam
+ * @since 2.0
+ */
+public class TmfRealTimestamp extends TmfTimestamp {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /**
+ * The timestamp raw value (mantissa)
+ */
+ private final long fValue;
+
+ /**
+ * The timestamp scale (magnitude)
+ */
+ private final int fScale;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Full constructor
+ *
+ * @param value
+ * the timestamp value
+ * @param scale
+ * the timestamp scale
+ */
+ public TmfRealTimestamp(final long value, final int scale) {
+ fValue = value;
+ fScale = scale;
+ }
+
+ @Override
+ public long getValue() {
+ return fValue;
+ }
+
+ @Override
+ public int getScale() {
+ return fScale;
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012, 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ * Francois Chouinard - Standardize on the default toString()
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.tmf.core.timestamp;
+
+/**
+ * A simplified timestamp where scale and precision are set to 0.
+ *
+ * @author Francois Chouinard
+ * @since 2.0
+ */
+public class TmfSecondTimestamp extends TmfTimestamp {
+
+ private final long fValue;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Default constructor (value = 0)
+ */
+ public TmfSecondTimestamp() {
+ this(0);
+ }
+
+ /**
+ * Full constructor
+ *
+ * @param value
+ * the timestamp value
+ */
+ public TmfSecondTimestamp(final long value) {
+ fValue = value;
+ }
+
+ @Override
+ public int getScale() {
+ return ITmfTimestamp.SECOND_SCALE;
+ }
+
+ @Override
+ public long getValue() {
+ return fValue;
+ }
+
+ // ------------------------------------------------------------------------
+ // ITmfTimestamp
+ // ------------------------------------------------------------------------
+
+ @Override
+ public ITmfTimestamp normalize(final long offset, final int scale) {
+ if (scale == ITmfTimestamp.SECOND_SCALE) {
+ return TmfTimestamp.fromSeconds(saturatedAdd(getValue(), offset));
+ }
+ return super.normalize(offset, scale);
+ }
+
+ @Override
+ public int compareTo(final ITmfTimestamp ts) {
+ if (ts instanceof TmfSecondTimestamp) {
+ final long delta = getValue() - ts.getValue();
+ return (delta == 0) ? 0 : (delta > 0) ? 1 : -1;
+ }
+ return super.compareTo(ts);
+ }
+
+ @Override
+ public ITmfTimestamp getDelta(final ITmfTimestamp ts) {
+ if (ts instanceof TmfSecondTimestamp) {
+ return new TmfTimestampDelta(getValue() - ts.getValue());
+ }
+ return super.getDelta(ts);
+ }
+
+ // ------------------------------------------------------------------------
+ // Object
+ // ------------------------------------------------------------------------
+
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
+
+ @Override
+ public boolean equals(final Object other) {
+ if (this == other) {
+ return true;
+ }
+ if (other == null) {
+ return false;
+ }
+ if (!(other instanceof TmfSecondTimestamp)) {
+ return super.equals(other);
+ }
+ final TmfSecondTimestamp ts = (TmfSecondTimestamp) other;
+
+ return compareTo(ts) == 0;
+ }
+
+}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2012, 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- * Francois Chouinard - Standardize on the default toString()
- *******************************************************************************/
-
-package org.eclipse.tracecompass.tmf.core.timestamp;
-
-/**
- * A simplified timestamp where scale and precision are set to 0.
- *
- * @author Francois Chouinard
- */
-public class TmfSimpleTimestamp extends TmfTimestamp {
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Default constructor (value = 0)
- */
- public TmfSimpleTimestamp() {
- this(0);
- }
-
- /**
- * Full constructor
- *
- * @param value the timestamp value
- */
- public TmfSimpleTimestamp(final long value) {
- super(value, 0);
- }
-
- /**
- * Copy constructor.
- *
- * If the parameter is not a TmfSimpleTimestamp, the timestamp will be
- * scaled to seconds, and the precision will be discarded.
- *
- * @param timestamp
- * The timestamp to copy
- */
- public TmfSimpleTimestamp(final ITmfTimestamp timestamp) {
- super(timestamp.normalize(0, ITmfTimestamp.SECOND_SCALE).getValue(), 0);
- }
-
- // ------------------------------------------------------------------------
- // ITmfTimestamp
- // ------------------------------------------------------------------------
-
- @Override
- public ITmfTimestamp normalize(final long offset, final int scale) {
- if (scale == ITmfTimestamp.SECOND_SCALE) {
- return new TmfSimpleTimestamp(saturatedAdd(getValue(), offset));
- }
- return super.normalize(offset, scale);
- }
-
- @Override
- public int compareTo(final ITmfTimestamp ts) {
- if (ts instanceof TmfSimpleTimestamp) {
- final long delta = getValue() - ts.getValue();
- return (delta == 0) ? 0 : (delta > 0) ? 1 : -1;
- }
- return super.compareTo(ts);
- }
-
- @Override
- public ITmfTimestamp getDelta(final ITmfTimestamp ts) {
- if (ts instanceof TmfSimpleTimestamp) {
- return new TmfTimestampDelta(getValue() - ts.getValue());
- }
- return super.getDelta(ts);
- }
-
- // ------------------------------------------------------------------------
- // Object
- // ------------------------------------------------------------------------
-
- @Override
- public int hashCode() {
- return super.hashCode();
- }
-
- @Override
- public boolean equals(final Object other) {
- if (this == other) {
- return true;
- }
- if (other == null) {
- return false;
- }
- if (!(other instanceof TmfSimpleTimestamp)) {
- return super.equals(other);
- }
- final TmfSimpleTimestamp ts = (TmfSimpleTimestamp) other;
-
- return compareTo(ts) == 0;
- }
-
-}
/**
* A generic timestamp implementation. The timestamp is represented by the tuple
- * { value, scale, precision }. By default, timestamps are scaled in seconds.
+ * { value, scale, precision }.
*
* @author Francois Chouinard
*/
-public class TmfTimestamp implements ITmfTimestamp {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
-
+public abstract class TmfTimestamp implements ITmfTimestamp {
/**
- * The beginning of time
- */
- public static final @NonNull ITmfTimestamp BIG_BANG = new TmfTimestamp(Long.MIN_VALUE, Integer.MAX_VALUE);
-
- /**
- * The end of time
- */
- public static final @NonNull ITmfTimestamp BIG_CRUNCH = new TmfTimestamp(Long.MAX_VALUE, Integer.MAX_VALUE);
-
- /**
- * Zero
- */
- public static final @NonNull ITmfTimestamp ZERO = new TmfTimestamp(0, 0);
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- /**
- * The timestamp raw value (mantissa)
+ * Create a timestamp.
+ *
+ * @param value
+ * the value in nanoseconds
+ * @return the timestamp
+ * @since 2.0
*/
- private final long fValue;
+ public static @NonNull ITmfTimestamp fromNanos(long value) {
+ return new TmfNanoTimestamp(value);
+ }
/**
- * The timestamp scale (magnitude)
+ * Create a timestamp.
+ *
+ * @param value
+ * the value in microseconds
+ * @return the timestamp
+ * @since 2.0
*/
- private final int fScale;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
+ public static @NonNull ITmfTimestamp fromMicros(long value) {
+ return create(value, ITmfTimestamp.MICROSECOND_SCALE);
+ }
/**
- * Default constructor
+ * Create a timestamp.
+ *
+ * @param value
+ * the value in milliseconds
+ * @return the timestamp
+ * @since 2.0
*/
- public TmfTimestamp() {
- this(0, ITmfTimestamp.SECOND_SCALE);
+ public static @NonNull ITmfTimestamp fromMillis(long value) {
+ return create(value, ITmfTimestamp.MILLISECOND_SCALE);
}
/**
- * Simple constructor (scale = 0)
+ * Create a timestamp.
*
* @param value
- * the timestamp value
+ * the value in seconds
+ * @return the timestamp
+ * @since 2.0
*/
- public TmfTimestamp(final long value) {
- this(value, ITmfTimestamp.SECOND_SCALE);
+ public static @NonNull ITmfTimestamp fromSeconds(long value) {
+ return new TmfSecondTimestamp(value);
}
/**
- * Full constructor
+ * Create a timestamp.
*
- * @param value
- * the timestamp value
- * @param scale
- * the timestamp scale
+ * @param bufferIn
+ * the byte buffer to read the timestamp from.
+ * @return the timestamp
+ * @since 2.0
*/
- public TmfTimestamp(final long value, final int scale) {
- fValue = value;
- fScale = scale;
+ public static @NonNull ITmfTimestamp create(ByteBuffer bufferIn) {
+ return create(bufferIn.getLong(), bufferIn.getInt());
}
/**
- * Copy constructor
+ * Create a timestamp.
*
- * @param timestamp
- * the timestamp to copy
+ * @param value
+ * the value in time, the unit is specified by the scale
+ * @param scale
+ * the scale of the timestamp with respect to seconds, so a
+ * nanosecond would be -9 (10e-9) and a megasecond would be 6
+ * (10e6)
+ * @return the timestamp
+ * @since 2.0
*/
- public TmfTimestamp(final ITmfTimestamp timestamp) {
- if (timestamp == null) {
- throw new IllegalArgumentException();
+ public static @NonNull ITmfTimestamp create(long value, int scale) {
+ if (scale == ITmfTimestamp.NANOSECOND_SCALE) {
+ return fromNanos(value);
}
- fValue = timestamp.getValue();
- fScale = timestamp.getScale();
+ if (scale == ITmfTimestamp.SECOND_SCALE) {
+ return fromSeconds(value);
+ }
+ return createOther(value, scale);
}
/**
- * Copies a timestamp but with a new time value
+ * Write the time stamp to the ByteBuffer so that it can be saved to disk.
*
- * @param timestamp
- * The timestamp to copy
- * @param newvalue
- * The value the new timestamp will have
+ * @param bufferOut
+ * the buffer to write to
+ * @param ts
+ * the timestamp to write
+ * @since 2.0
*/
- public TmfTimestamp(ITmfTimestamp timestamp, long newvalue) {
- if (timestamp == null) {
- throw new IllegalArgumentException();
- }
- fValue = newvalue;
- fScale = timestamp.getScale();
+ public static void serialize(ByteBuffer bufferOut, ITmfTimestamp ts) {
+ bufferOut.putLong(ts.getValue());
+ bufferOut.putInt(ts.getScale());
+ }
+
+ private static @NonNull ITmfTimestamp createOther(long value, int scale) {
+ return new TmfRealTimestamp(value, scale);
}
// ------------------------------------------------------------------------
- // ITmfTimestamp
+ // Constants
// ------------------------------------------------------------------------
/**
- * Construct the timestamp from the ByteBuffer.
- *
- * @param bufferIn
- * the buffer to read from
+ * The beginning of time
*/
- public TmfTimestamp(ByteBuffer bufferIn) {
- this(bufferIn.getLong(), bufferIn.getInt());
- }
+ public static final @NonNull ITmfTimestamp BIG_BANG = new TmfRealTimestamp(Long.MIN_VALUE, Integer.MAX_VALUE);
- @Override
- public long getValue() {
- return fValue;
- }
+ /**
+ * The end of time
+ */
+ public static final @NonNull ITmfTimestamp BIG_CRUNCH = new TmfRealTimestamp(Long.MAX_VALUE, Integer.MAX_VALUE);
- @Override
- public int getScale() {
- return fScale;
- }
+ /**
+ * Zero
+ */
+ public static final @NonNull ITmfTimestamp ZERO = new TmfRealTimestamp(0, 0);
+
+ // ------------------------------------------------------------------------
+ // ITmfTimestamp
+ // ------------------------------------------------------------------------
- private static final long scalingFactors[] = new long[] {
+ /**
+ * Scaling factors to help scale
+ *
+ * @since 2.0
+ */
+ protected static final long SCALING_FACTORS[] = new long[] {
1L,
10L,
100L,
}
if (value == 0) {
- return new TmfTimestamp(offset, scale);
+ return create(offset, scale);
}
// First, scale the timestamp
if (getScale() != scale) {
final int scaleDiff = Math.abs(getScale() - scale);
- if (scaleDiff >= scalingFactors.length) {
+ if (scaleDiff >= SCALING_FACTORS.length) {
if (getScale() < scale) {
value = 0;
} else {
value = value > 0 ? Long.MAX_VALUE : Long.MIN_VALUE;
}
} else {
- final long scalingFactor = scalingFactors[scaleDiff];
+ final long scalingFactor = SCALING_FACTORS[scaleDiff];
if (getScale() < scale) {
value /= scalingFactor;
} else {
value = saturatedAdd(value, offset);
- return new TmfTimestamp(value, scale);
+ return create(value, scale);
}
@Override
public ITmfTimestamp getDelta(final ITmfTimestamp ts) {
- final ITmfTimestamp nts = ts.normalize(0, fScale);
- final long value = fValue - nts.getValue();
- return new TmfTimestampDelta(value, fScale);
+ final int scale = getScale();
+ final ITmfTimestamp nts = ts.normalize(0, scale);
+ final long value = getValue() - nts.getValue();
+ return new TmfTimestampDelta(value, scale);
}
@Override
@Override
public int compareTo(final ITmfTimestamp ts) {
+ long value = getValue();
+ int scale = getScale();
// Check the corner cases (we can't use equals() because it uses
// compareTo()...)
if (ts == null) {
return 1;
}
- if (this == ts || (fValue == ts.getValue() && fScale == ts.getScale())) {
+ if (this == ts || (value == ts.getValue() && scale == ts.getScale())) {
return 0;
}
- if ((fValue == BIG_BANG.getValue() && fScale == BIG_BANG.getScale()) || (ts.getValue() == BIG_CRUNCH.getValue() && ts.getScale() == BIG_CRUNCH.getScale())) {
+ if ((value == BIG_BANG.getValue() && scale == BIG_BANG.getScale()) || (ts.getValue() == BIG_CRUNCH.getValue() && ts.getScale() == BIG_CRUNCH.getScale())) {
return -1;
}
- if ((fValue == BIG_CRUNCH.getValue() && fScale == BIG_CRUNCH.getScale()) || (ts.getValue() == BIG_BANG.getValue() && ts.getScale() == BIG_BANG.getScale())) {
+ if ((value == BIG_CRUNCH.getValue() && scale == BIG_CRUNCH.getScale()) || (ts.getValue() == BIG_BANG.getValue() && ts.getScale() == BIG_BANG.getScale())) {
return 1;
}
- final ITmfTimestamp nts = ts.normalize(0, fScale);
+ final ITmfTimestamp nts = ts.normalize(0, scale);
if ((nts.getValue() == 0 && ts.getValue() != 0) || (ts.getValue() != Long.MAX_VALUE && nts.getValue() == Long.MAX_VALUE) || (ts.getValue() != Long.MIN_VALUE && nts.getValue() == Long.MIN_VALUE)) {
// Scaling error. We can figure it out nonetheless.
// First, look at the sign of the mantissa
- final long value = ts.getValue();
- if (fValue == 0 && value == 0) {
+ final long otherValue = ts.getValue();
+ if (value == 0 && otherValue == 0) {
return 0;
}
- if (fValue < 0 && value >= 0) {
+ if (value < 0 && otherValue >= 0) {
return -1;
}
- if (fValue >= 0 && value < 0) {
+ if (value >= 0 && otherValue < 0) {
return 1;
}
// Otherwise, just compare the scales
- final int scale = ts.getScale();
- return (fScale > scale) ? (fValue >= 0) ? 1 : -1 : (fValue >= 0) ? -1 : 1;
+ final int otherScale = ts.getScale();
+ return (scale > otherScale) ? (otherValue >= 0) ? 1 : -1 : (otherValue >= 0) ? -1 : 1;
}
- final long delta = fValue - nts.getValue();
+ final long delta = value - nts.getValue();
return Long.compare(delta, 0);
}
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + (int) (fValue ^ (fValue >>> 32));
- result = prime * result + fScale;
+ final long value = getValue();
+ result = prime * result + (int) (value ^ (value >>> 32));
+ result = prime * result + getScale();
return result;
}
return format.format(0);
}
}
-
- /**
- * Write the time stamp to the ByteBuffer so that it can be saved to disk.
- *
- * @param bufferOut
- * the buffer to write to
- */
- public void serialize(ByteBuffer bufferOut) {
- bufferOut.putLong(fValue);
- bufferOut.putInt(fScale);
- }
}
import java.util.TimeZone;
/**
- * A generic timestamp implementation for delta between timestamps.
- * The toString() method takes negative values into consideration.
+ * A generic timestamp implementation for delta between timestamps. The
+ * toString() method takes negative values into consideration.
*
* @author Bernd Hufmann
*/
-public class TmfTimestampDelta extends TmfTimestamp {
+public class TmfTimestampDelta extends TmfRealTimestamp {
// ------------------------------------------------------------------------
// Members
* Default constructor
*/
public TmfTimestampDelta() {
- super();
+ super(0, ITmfTimestamp.SECOND_SCALE);
}
/**
* Simple constructor (scale = precision = 0)
*
- * @param value the timestamp value
+ * @param value
+ * the timestamp value
*/
public TmfTimestampDelta(long value) {
- super(value);
+ super(value, ITmfTimestamp.SECOND_SCALE);
}
/**
- * Simple constructor (precision = 0)
+ * Constructor
*
- * @param value the timestamp value
- * @param scale the timestamp scale
+ * @param value
+ * the timestamp value
+ * @param scale
+ * the timestamp scale
*/
public TmfTimestampDelta(long value, int scale) {
super(value, scale);
}
-
/**
* Copy constructor
*
- * @param timestamp the timestamp to copy
+ * @param timestamp
+ * the timestamp to copy
*/
public TmfTimestampDelta(ITmfTimestamp timestamp) {
- super(timestamp);
+ super(timestamp.getValue(), timestamp.getScale());
}
// ------------------------------------------------------------------------
import org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform;
import org.eclipse.tracecompass.tmf.core.synchronization.TimestampTransformFactory;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.indexer.ITmfTraceIndexer;
@Override
public ITmfTimestamp getInitialRangeOffset() {
final long DEFAULT_INITIAL_OFFSET_VALUE = (1L * 100 * 1000 * 1000); // .1sec
- return new TmfTimestamp(DEFAULT_INITIAL_OFFSET_VALUE, ITmfTimestamp.NANOSECOND_SCALE);
+ return TmfTimestamp.fromNanos(DEFAULT_INITIAL_OFFSET_VALUE);
}
@Override
@Override
public @NonNull ITmfTimestamp createTimestamp(long ts) {
- return new TmfNanoTimestamp(getTimestampTransform().transform(ts));
+ return TmfTimestamp.fromNanos(getTimestampTransform().transform(ts));
}
// ------------------------------------------------------------------------
long offset = trace.getInitialRangeOffset().toNanos();
long endTime = startTs.toNanos() + offset;
final TmfTimeRange selectionRange = new TmfTimeRange(startTs, startTs);
- final TmfTimeRange windowRange = new TmfTimeRange(startTs, new TmfTimestamp(endTime, ITmfTimestamp.NANOSECOND_SCALE));
+ final TmfTimeRange windowRange = new TmfTimeRange(startTs, TmfTimestamp.fromNanos(endTime));
final TmfTraceContext startCtx = trace.createTraceContext(selectionRange, windowRange, editorFile, null);
fLocation.serialize(bufferOut);
// Always serialize as base TmfTimestamp, this should be sufficient for indexing.
// If not, we can add API for the test to restore the time stamp, similarly to the location.
- TmfTimestamp t = new TmfTimestamp(fTimestamp);
- t.serialize(bufferOut);
+ TmfTimestamp.serialize(bufferOut, fTimestamp);
bufferOut.putLong(fCheckpointRank);
}
* the buffer to read from
*/
public TmfTimestampLocation(ByteBuffer bufferIn) {
- super(new TmfTimestamp(bufferIn));
+ super(TmfTimestamp.create(bufferIn));
}
@Override
@Override
public void serialize(ByteBuffer bufferOut) {
- TmfTimestamp t = new TmfTimestamp(getLocationInfo());
- t.serialize(bufferOut);
+ TmfTimestamp.serialize(bufferOut, getLocationInfo());
}
}
package org.eclipse.tracecompass.tmf.remote.core.tests.shell;
import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
-import static org.junit.Assume.assumeTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
import java.util.Arrays;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
countEventsInModel(nbEvents, model);
final TmfTimeRange timeRange_0 = new TmfTimeRange(
- new TmfTimestamp(5L, ITmfTimestamp.NANOSECOND_SCALE),
- new TmfTimestamp(10L, ITmfTimestamp.NANOSECOND_SCALE));
+ TmfTimestamp.fromNanos(5L),
+ TmfTimestamp.fromNanos(10L));
model.countLostEvent(timeRange_0, nbLostEvents_0, false);
final TmfTimeRange timeRange_1 = new TmfTimeRange(
- new TmfTimestamp(18L, ITmfTimestamp.NANOSECOND_SCALE),
- new TmfTimestamp(27L, ITmfTimestamp.NANOSECOND_SCALE));
+ TmfTimestamp.fromNanos(18L),
+ TmfTimestamp.fromNanos(27L));
model.countLostEvent(timeRange_1, nbLostEvents_1, false);
HistogramScaledData result = model.scaleTo(nbBuckets, maxHeight, 1);
countEventsInModel(nbEvents, model);
final TmfTimeRange timeRange_0 = new TmfTimeRange(
- new TmfTimestamp(5L, ITmfTimestamp.NANOSECOND_SCALE),
- new TmfTimestamp(10L, ITmfTimestamp.NANOSECOND_SCALE));
+ TmfTimestamp.fromNanos(5L),
+ TmfTimestamp.fromNanos(10L));
model.countLostEvent(timeRange_0, nbLostEvents_0, false);
final TmfTimeRange timeRange_1 = new TmfTimeRange(
- new TmfTimestamp(11L, ITmfTimestamp.NANOSECOND_SCALE),
- new TmfTimestamp(18L, ITmfTimestamp.NANOSECOND_SCALE));
+ TmfTimestamp.fromNanos(11L),
+ TmfTimestamp.fromNanos(18L));
model.countLostEvent(timeRange_1, nbLostEvents_1, false);
HistogramScaledData result = model.scaleTo(nbBuckets, maxHeight, 1);
countEventsInModel(nbEvents, model);
final TmfTimeRange timeRange_0 = new TmfTimeRange(
- new TmfTimestamp(18L, ITmfTimestamp.NANOSECOND_SCALE),
- new TmfTimestamp(22L, ITmfTimestamp.NANOSECOND_SCALE));
+ TmfTimestamp.fromNanos(18L),
+ TmfTimestamp.fromNanos(22L));
model.countLostEvent(timeRange_0, nbLostEvents_0, false);
final TmfTimeRange timeRange_2 = new TmfTimeRange(
- new TmfTimestamp(28L, ITmfTimestamp.NANOSECOND_SCALE),
- new TmfTimestamp(29L, ITmfTimestamp.NANOSECOND_SCALE));
+ TmfTimestamp.fromNanos(28L),
+ TmfTimestamp.fromNanos(29L));
model.countLostEvent(timeRange_2, nbLostEvents_2, false);
final TmfTimeRange timeRange_1 = new TmfTimeRange(
- new TmfTimestamp(11L, ITmfTimestamp.NANOSECOND_SCALE),
- new TmfTimestamp(26L, ITmfTimestamp.NANOSECOND_SCALE));
+ TmfTimestamp.fromNanos(11L),
+ TmfTimestamp.fromNanos(26L));
model.countLostEvent(timeRange_1, nbLostEvents_1, false);
HistogramScaledData result = model.scaleTo(nbBuckets, maxHeight, 1);
countEventsInModel(nbEvents, model);
final TmfTimeRange timeRange_0 = new TmfTimeRange(
- new TmfTimestamp(11L, ITmfTimestamp.NANOSECOND_SCALE),
- new TmfTimestamp(26L, ITmfTimestamp.NANOSECOND_SCALE));
+ TmfTimestamp.fromNanos(11L),
+ TmfTimestamp.fromNanos(26L));
model.countLostEvent(timeRange_0, nbLostEvents_0, false);
HistogramScaledData result = model.scaleTo(nbBuckets, maxHeight, 1);
HistogramDataModel model = new HistogramDataModel(nbBuckets);
final TmfTimeRange timeRange_0 = new TmfTimeRange(
- new TmfTimestamp(5L, ITmfTimestamp.NANOSECOND_SCALE),
- new TmfTimestamp(10L, ITmfTimestamp.NANOSECOND_SCALE));
+ TmfTimestamp.fromNanos(5L),
+ TmfTimestamp.fromNanos(10L));
model.countLostEvent(timeRange_0, nbLostEvents_0, false);
int firstNonLostEventTime = 6;
countEventsInModel(nbEvents, model, 0, firstNonLostEventTime);
final TmfTimeRange timeRange_1 = new TmfTimeRange(
- new TmfTimestamp(18L, ITmfTimestamp.NANOSECOND_SCALE),
- new TmfTimestamp(27L, ITmfTimestamp.NANOSECOND_SCALE));
+ TmfTimestamp.fromNanos(18L),
+ TmfTimestamp.fromNanos(27L));
model.countLostEvent(timeRange_1, nbLostEvents_1, false);
HistogramScaledData result = model.scaleTo(nbBuckets, maxHeight, 1);
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.Messages;
import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfBaseColumnData;
+import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfBaseColumnData.ITmfColumnPercentageProvider;
import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfBaseColumnDataProvider;
import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfStatisticsTree;
import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode;
-import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfBaseColumnData.ITmfColumnPercentageProvider;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.junit.Test;
private final String fLabel2 = "label3";
private final String[] fLabels = new String[] { fLabel0, fLabel1, fLabel2 };
- private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2);
- private final TmfTimestamp fTimestamp2 = new TmfTimestamp(12350, (byte) 2);
- private final TmfTimestamp fTimestamp3 = new TmfTimestamp(12355, (byte) 2);
+ private final ITmfTimestamp fTimestamp1 = TmfTimestamp.create(12345, (byte) 2);
+ private final ITmfTimestamp fTimestamp2 = TmfTimestamp.create(12350, (byte) 2);
+ private final ITmfTimestamp fTimestamp3 = TmfTimestamp.create(12355, (byte) 2);
private final TmfEventType fType1 = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels));
private final TmfEventType fType2 = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels));
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfBaseColumnData;
+import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfBaseColumnData.ITmfColumnPercentageProvider;
import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfStatisticsTree;
import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode;
-import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfBaseColumnData.ITmfColumnPercentageProvider;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.junit.Before;
import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.junit.Test;
private final String fLabel2 = "label3";
private final String[] fLabels = new String[] { fLabel0, fLabel1, fLabel2 };
- private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2);
- private final TmfTimestamp fTimestamp2 = new TmfTimestamp(12350, (byte) 2);
- private final TmfTimestamp fTimestamp3 = new TmfTimestamp(12355, (byte) 2);
+ private final ITmfTimestamp fTimestamp1 = TmfTimestamp.create(12345, (byte) 2);
+ private final ITmfTimestamp fTimestamp2 = TmfTimestamp.create(12350, (byte) 2);
+ private final ITmfTimestamp fTimestamp3 = TmfTimestamp.create(12355, (byte) 2);
private final TmfEventType fType1 = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels));
private final TmfEventType fType2 = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels));
import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.junit.Test;
private final String fLabel1 = "label2";
private final String[] fLabels = new String[] { fLabel0, fLabel1 };
- private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2);
- private final TmfTimestamp fTimestamp2 = new TmfTimestamp(12350, (byte) 2);
+ private final ITmfTimestamp fTimestamp1 = TmfTimestamp.create(12345, (byte) 2);
+ private final ITmfTimestamp fTimestamp2 = TmfTimestamp.create(12350, (byte) 2);
private final TmfEventType fType1 = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels));
private final TmfEventType fType2 = new TmfEventType(fTypeId2, TmfEventField.makeRoot(fLabels));
*******************************************************************************/
package org.eclipse.tracecompass.tmf.ui.tests.views.uml2sd.loader;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
/**
* Interface for testing signal handling within TmfUml2SD
/**
* @return the expected current time.
*/
- TmfTimestamp getCurrentTime();
+ ITmfTimestamp getCurrentTime();
/**
* Sets the expected current time
* @param currentTime Time to set
*/
- void setCurrentTime(TmfTimestamp currentTime);
+ void setCurrentTime(ITmfTimestamp currentTime);
/**
* @return the expected current time range.
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
+import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.GraphNode;
import java.util.List;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
+import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.GraphNode;
import org.eclipse.tracecompass.tmf.core.component.TmfComponent;
import org.eclipse.tracecompass.tmf.core.signal.TmfEndSynchSignal;
-import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal;
+import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
import org.eclipse.tracecompass.tmf.core.signal.TmfStartSynchSignal;
-import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
+import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
/**
* Class to implement that certain signals are sent as well as are sent with correct content.
private boolean fIsRangeError = false;
private Object fSource = null;
- private TmfTimestamp fCurrentTimestamp = null;
+ private ITmfTimestamp fCurrentTimestamp = null;
private TmfTimeRange fCurrentTimeRange = null;
// ------------------------------------------------------------------------
}
@Override
- public TmfTimestamp getCurrentTime() {
+ public ITmfTimestamp getCurrentTime() {
return fCurrentTimestamp;
}
@Override
- public void setCurrentTime(TmfTimestamp currentTime) {
- fCurrentTimestamp = currentTime == null ? null : new TmfTimestamp(currentTime);
+ public void setCurrentTime(ITmfTimestamp currentTime) {
+ fCurrentTimestamp = currentTime;
}
@Override
*
*/
public class Uml2SDTestTimestamp extends TmfTimestamp {
+
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
+ private final long fValue;
+ private final int fScale;
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
* @param value time as long value (nanoseconds)
*/
public Uml2SDTestTimestamp(long value) {
- super(value, IUml2SDTestConstants.TIME_SCALE);
+ fValue = value;
+ fScale = IUml2SDTestConstants.TIME_SCALE;
}
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
+ @Override
+ public long getValue() {
+ return fValue;
+ }
+
+ @Override
+ public int getScale() {
+ return fScale;
+ }
+
}
// else if (i == 6)
// m3.setTime(new TmfTimestamp(i));
// else
- m3.setTime(new TmfTimestamp(i + 1));
+ m3.setTime(TmfTimestamp.fromSeconds(i + 1));
}
for (int i = testFrame.lifeLinesCount() - 1; i > 0; i--) {
m.setEndLifeline(testFrame.getLifeline(3));
m.setStartOccurrence(2);
m.setEndOccurrence(6);
- m.setStartTime(new TmfTimestamp(2));
- m.setEndTime(new TmfTimestamp(6));
+ m.setStartTime(TmfTimestamp.fromSeconds(2));
+ m.setEndTime(TmfTimestamp.fromSeconds(6));
m.setName("*******************Async TEST ****************");
testFrame.addMessage(m);
v.setFrame(testFrame);
fields[2] = new TmfEventField("signal", signal, null);
ITmfEventField tmfContent = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, content, fields);
- ITmfEvent tmfEvent = new TmfEvent(fEventStream, ITmfContext.UNKNOWN_RANK, new TmfTimestamp(ts, -9), tmfEventType, tmfContent);
+ ITmfEvent tmfEvent = new TmfEvent(fEventStream, ITmfContext.UNKNOWN_RANK, TmfTimestamp.create(ts, -9), tmfEventType, tmfContent);
return tmfEvent;
} catch (final EOFException e) {
package org.eclipse.tracecompass.internal.tmf.ui.markers;
-import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.AbstractTmfTraceAdapterFactory;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEventSource;
/**
import org.eclipse.tracecompass.internal.tmf.ui.Activator;
import org.eclipse.tracecompass.internal.tmf.ui.Messages;
import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTraceDefinition;
+import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlInputAttribute;
import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlInputElement;
import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTrace;
import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTraceDefinition;
-import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlInputAttribute;
import org.eclipse.tracecompass.tmf.core.project.model.TmfTraceType;
import org.eclipse.tracecompass.tmf.core.project.model.TraceTypeHelper;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.tracecompass.tmf.core.signal.TmfEventSelectedSignal;
+import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
-import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
public class OffsetDialog extends Dialog {
private static final int TREE_EDITOR_MIN_WIDTH = 50;
- private static final String EDITOR_KEY = "$editor$"; //$NON-NLS-1$
- private static final String WIDTH_KEY = "$width$"; //$NON-NLS-1$
+ private static final String EDITOR_KEY = "$editor$"; //$NON-NLS-1$
+ private static final String WIDTH_KEY = "$width$"; //$NON-NLS-1$
private static final TmfTimestampFormat TIME_FORMAT = new TmfTimestampFormat("yyyy-MM-dd HH:mm:ss.SSS SSS SSS"); //$NON-NLS-1$
private static final TmfTimestampFormat OFFSET_FORMAT = new TmfTimestampFormat("T.SSS SSS SSS"); //$NON-NLS-1$
ITmfTimestamp refTime = map.get(element);
long ref = refTime == null ? 0 : refTime.toNanos();
Long newVal = TIME_FORMAT.parseValue(string, ref);
- map.put((TmfTraceElement) element, new TmfNanoTimestamp(newVal));
+ map.put((TmfTraceElement) element, TmfTimestamp.fromNanos(newVal));
} catch (ParseException e) {
/* Ignore and reload previous value */
}
// Define the TableViewer
fViewer = new FilteredTree(parent, SWT.MULTI | SWT.H_SCROLL
| SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER, new PatternFilter() {
- @Override
- protected boolean isLeafMatch(Viewer viewer, Object element) {
- return wordMatches(((TmfTraceElement) element).getElementPath());
- }
- }, true);
+ @Override
+ protected boolean isLeafMatch(Viewer viewer, Object element) {
+ return wordMatches(((TmfTraceElement) element).getElementPath());
+ }
+ }, true);
// Make lines and make header visible
final Tree tree = fViewer.getViewer().getTree();
ITmfTimestamp targetTime = fTargetTimeMap.get(traceElement);
ITmfTimestamp refTime = fRefTimeMap.get(traceElement);
if (targetTime != null && refTime != null) {
- long offset = new TmfNanoTimestamp(targetTime).getValue() -
- new TmfNanoTimestamp(refTime).getValue();
+ long offset = targetTime.toNanos() -
+ refTime.toNanos();
fOffsetMap.put(traceElement, offset);
fViewer.getViewer().update(traceElement, null);
}
}
/* put temporary values in maps to pack according to time formats */
- fRefTimeMap.put(traces.get(0), new TmfNanoTimestamp());
- fTargetTimeMap.put(traces.get(0), new TmfNanoTimestamp());
+ fRefTimeMap.put(traces.get(0), TmfTimestamp.fromNanos(0));
+ fTargetTimeMap.put(traces.get(0), TmfTimestamp.fromNanos(0));
fViewer.getViewer().update(traces.get(0), null);
for (final TreeColumn treeColumn : tree.getColumns()) {
if (treeColumn.getResizable()) {
fRefTimeColumn.setWidth(0);
fRefTimeColumn.setResizable(false);
fButtonViewerColumn.getColumn().setWidth(0);
- fAdvancedMessageLabel.setText(""); //$NON-NLS-1$
+ fAdvancedMessageLabel.setText(""); //$NON-NLS-1$
}
private void setAdvancedMode() {
import java.util.Timer;
import java.util.TimerTask;
-import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
if (fTrace != null) {
setSelectionRange(currentBeginTime, currentEndTime);
- final ITmfTimestamp startTimestamp = new TmfTimestamp(getSelectionBeginTime(), ITmfTimestamp.NANOSECOND_SCALE);
- final ITmfTimestamp endTimestamp = new TmfTimestamp(getSelectionEndTime(), ITmfTimestamp.NANOSECOND_SCALE);
+ final ITmfTimestamp startTimestamp = TmfTimestamp.fromNanos(getSelectionBeginTime());
+ final ITmfTimestamp endTimestamp = TmfTimestamp.fromNanos(getSelectionEndTime());
TmfSelectionRangeUpdatedSignal signal = new TmfSelectionRangeUpdatedSignal(this, startTimestamp, endTimestamp);
broadcast(signal);
// Build the new time range; keep the current time
TmfTimeRange timeRange = new TmfTimeRange(
- new TmfTimestamp(getWindowStartTime(), ITmfTimestamp.NANOSECOND_SCALE),
- new TmfTimestamp(getWindowEndTime(), ITmfTimestamp.NANOSECOND_SCALE));
+ TmfTimestamp.fromNanos(getWindowStartTime()),
+ TmfTimestamp.fromNanos(getWindowEndTime()));
// Send the signal
TmfWindowRangeUpdatedSignal signal = new TmfWindowRangeUpdatedSignal(this, timeRange);
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
import org.eclipse.tracecompass.tmf.core.signal.TmfTraceUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
private final class ColumnMovedListener extends ControlAdapter {
/*
- * Make sure that the margin column is always first and keep the
- * column order variable up to date.
+ * Make sure that the margin column is always first and keep the column
+ * order variable up to date.
*/
@Override
public void controlMoved(ControlEvent e) {
GC gc = event.gc;
Color background = item.getBackground(event.index);
/*
- * Paint the background if it is not the default system color.
- * In Windows, if you let the widget draw the background, it
- * will not show the item's background color if the item is
- * selected or hot. If there are no style ranges and the item
- * background is the default system color, we do not want to
- * paint it or otherwise we would override the platform theme
- * (e.g. alternating colors).
+ * Paint the background if it is not the default system color. In
+ * Windows, if you let the widget draw the background, it will not
+ * show the item's background color if the item is selected or hot.
+ * If there are no style ranges and the item background is the
+ * default system color, we do not want to paint it or otherwise we
+ * would override the platform theme (e.g. alternating colors).
*/
if (styleRanges != null || !background.equals(item.getParent().getBackground())) {
// we will paint the table item's background
/*
* We will paint the table item's foreground. In Windows, if you
- * paint the background but let the widget draw the foreground,
- * it will override your background, unless the item is selected
- * or hot.
+ * paint the background but let the widget draw the foreground, it
+ * will override your background, unless the item is selected or
+ * hot.
*/
event.detail &= ~SWT.FOREGROUND;
/*
* Bug in Linux. The coordinates of the event have an origin
* that excludes the table header but the method toDisplay()
- * expects coordinates relative to an origin that includes
- * the table header.
+ * expects coordinates relative to an origin that includes the
+ * table header.
*/
int y = event.y;
if (IS_LINUX) {
* The events table search/filter/data keys
*
* @author Patrick Tasse
- * @noimplement This interface only contains Event Table specific
- * static definitions.
+ * @noimplement This interface only contains Event Table specific static
+ * definitions.
*/
public interface Key {
}
item.setText(itemStrings);
item.setData(tmfEvent);
- item.setData(Key.TIMESTAMP, new TmfTimestamp(tmfEvent.getTimestamp()));
+ item.setData(Key.TIMESTAMP, tmfEvent.getTimestamp());
item.setData(Key.RANK, rank);
final Collection<Long> markerIds = fBookmarksMap.get(rank);
/**
* Returns true if the column is a visible event column.
*
- * @param column the column
- * @return false if the column is the margin column or hidden, true otherwise
+ * @param column
+ * the column
+ * @return false if the column is the margin column or hidden, true
+ * otherwise
*/
private static boolean isVisibleEventColumn(TableColumn column) {
if (column.getData(Key.ASPECT) == TmfMarginColumn.MARGIN_ASPECT) {
bookmark.setAttribute(IMarker.MESSAGE, message.toString());
bookmark.setAttribute(IMarker.LOCATION, location);
bookmark.setAttribute(ITmfMarker.MARKER_RANK, rank.toString());
- bookmark.setAttribute(ITmfMarker.MARKER_TIME, Long.toString(new TmfNanoTimestamp(timestamp).getValue()));
+ bookmark.setAttribute(ITmfMarker.MARKER_TIME, Long.toString(timestamp.toNanos()));
bookmark.setAttribute(ITmfMarker.MARKER_COLOR, dialog.getColorValue().toString());
id[0] = bookmark.getId();
}
try {
String timeString = marker.getAttribute(ITmfMarker.MARKER_TIME, (String) null);
long time = Long.parseLong(timeString);
- tsBegin = new TmfNanoTimestamp(time);
+ tsBegin = TmfTimestamp.fromNanos(time);
String durationString = marker.getAttribute(ITmfMarker.MARKER_DURATION, (String) null);
long duration = Long.parseLong(durationString);
- tsEnd = new TmfNanoTimestamp(time + duration);
+ tsEnd = TmfTimestamp.fromNanos(time + duration);
} catch (NumberFormatException e) {
/* ignored */
}
final TmfEventRequest subRequest = new TmfEventRequest(ITmfEvent.class,
TmfTimeRange.ETERNITY, 0, 1, ExecutionType.FOREGROUND) {
- TmfTimestamp ts = new TmfTimestamp(signal.getBeginTime());
- TmfTimestamp tf = new TmfTimestamp(signal.getEndTime());
+ ITmfTimestamp ts = signal.getBeginTime();
+ ITmfTimestamp tf = signal.getEndTime();
@Override
public void handleSuccess() {
contextEnd = fTrace.seekEvent(te);
rankEnd = contextEnd.getRank();
contextEnd.dispose();
- /* To include all events at the begin time, seek at the next nanosecond and then use the previous rank */
+ /*
+ * To include all events at the begin time, seek at the
+ * next nanosecond and then use the previous rank
+ */
tb = timestampBegin.normalize(1, ITmfTimestamp.NANOSECOND_SCALE);
if (tb.compareTo(fTrace.getEndTime()) <= 0) {
contextBegin = fTrace.seekEvent(tb);
rankBegin = ITmfContext.UNKNOWN_RANK;
}
rankBegin = (rankBegin == ITmfContext.UNKNOWN_RANK ? fTrace.getNbEvents() : rankBegin) - 1;
- /* If no events in selection range, select only the next event */
+ /*
+ * If no events in selection range, select only the next
+ * event
+ */
rankBegin = rankBegin >= rankEnd ? rankBegin : rankEnd;
} else {
tb = timestampBegin;
contextBegin = fTrace.seekEvent(tb);
rankBegin = contextBegin.getRank();
contextBegin.dispose();
- /* To include all events at the end time, seek at the next nanosecond and then use the previous rank */
+ /*
+ * To include all events at the end time, seek at the
+ * next nanosecond and then use the previous rank
+ */
te = timestampEnd.normalize(1, ITmfTimestamp.NANOSECOND_SCALE);
if (te.compareTo(fTrace.getEndTime()) <= 0) {
contextEnd = fTrace.seekEvent(te);
rankEnd = ITmfContext.UNKNOWN_RANK;
}
rankEnd = (rankEnd == ITmfContext.UNKNOWN_RANK ? fTrace.getNbEvents() : rankEnd) - 1;
- /* If no events in selection range, select only the next event */
+ /*
+ * If no events in selection range, select only the next
+ * event
+ */
rankEnd = rankEnd >= rankBegin ? rankEnd : rankBegin;
}
return new Pair<>(Long.valueOf(rankBegin), Long.valueOf(rankEnd));
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal;
-import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
+import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
+import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.ui.viewers.TmfTimeViewer;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.swtchart.IAxis;
import org.swtchart.ISeries;
* Constructor for a tool tip provider.
*
* @param tmfChartViewer
- * - the parent chart viewer
+ * - the parent chart viewer
*/
public TmfClosestDataPointTooltipProvider(ITmfChartTimeProvider tmfChartViewer) {
super(tmfChartViewer);
double currentDistance = xs * xs + ys * ys;
/*
- * Check for smallest distance to mouse position and
- * only consider it if the mouse is close the data point.
+ * Check for smallest distance to mouse position and only
+ * consider it if the mouse is close the data point.
*/
if ((currentDistance < smallestDistance) && (currentDistance < (HIGHLIGHT_RADIUS * HIGHLIGHT_RADIUS))) {
smallestDistance = currentDistance;
}
String tooltip = null;
if (param != null) {
- tooltip = createToolTipText(param);
+ tooltip = createToolTipText(param);
if (tooltip != null) {
fIsHighlight = true;
getChart().redraw();
}
}
/*
- * Note that tooltip might be null which will clear the
- * previous tooltip string. This is intentional.
+ * Note that tooltip might be null which will clear the previous
+ * tooltip string. This is intentional.
*/
getChart().getPlotArea().setToolTipText(tooltip);
}
if ((xS != null) && (yS != null) && (dataIndex < xS.length) && (dataIndex < yS.length)) {
StringBuffer buffer = new StringBuffer();
buffer.append("x="); //$NON-NLS-1$
- buffer.append(new TmfTimestamp((long) xS[dataIndex] + getChartViewer().getTimeOffset(), ITmfTimestamp.NANOSECOND_SCALE).toString());
+ buffer.append(TmfTimestamp.fromNanos((long) xS[dataIndex] + getChartViewer().getTimeOffset()).toString());
buffer.append('\n');
buffer.append("y="); //$NON-NLS-1$
buffer.append((long) yS[dataIndex]);
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackListener;
-import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.swtchart.IAxis;
/* set tooltip of current data point */
StringBuffer buffer = new StringBuffer();
buffer.append("x="); //$NON-NLS-1$
- buffer.append(new TmfTimestamp((long) xCoordinate + viewer.getTimeOffset(), ITmfTimestamp.NANOSECOND_SCALE).toString());
+ buffer.append(TmfTimestamp.fromNanos((long) xCoordinate + viewer.getTimeOffset()).toString());
buffer.append("\n"); //$NON-NLS-1$
buffer.append("y="); //$NON-NLS-1$
buffer.append((long) yCoordinate);
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.ITmfChartTimeProvider;
import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.TmfBaseProvider;
/* set tooltip of closest data point */
StringBuffer buffer = new StringBuffer();
buffer.append("Range=["); //$NON-NLS-1$
- buffer.append(new TmfTimestamp((long) rangeStart + viewer.getTimeOffset(), ITmfTimestamp.NANOSECOND_SCALE).toString());
+ buffer.append(TmfTimestamp.fromNanos((long) rangeStart + viewer.getTimeOffset()).toString());
buffer.append(',');
- buffer.append(new TmfTimestamp((long) rangeEnd + viewer.getTimeOffset(), ITmfTimestamp.NANOSECOND_SCALE).toString());
+ buffer.append(TmfTimestamp.fromNanos((long) rangeEnd + viewer.getTimeOffset()).toString());
buffer.append("]\n"); //$NON-NLS-1$
buffer.append("y="); //$NON-NLS-1$
buffer.append((long) y);
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackListener;
-import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.ITmfChartTimeProvider;
import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.TmfBaseProvider;
}
StringBuffer buffer = new StringBuffer();
buffer.append("time="); //$NON-NLS-1$
- buffer.append(new TmfTimestamp((long) xCoordinate + getChartViewer().getTimeOffset(), ITmfTimestamp.NANOSECOND_SCALE).toString());
+ buffer.append(TmfTimestamp.fromNanos((long) xCoordinate + getChartViewer().getTimeOffset()).toString());
buffer.append('\n');
/* For each series, get the value at the index */
import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal;
import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampDelta;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
import org.eclipse.tracecompass.tmf.ui.editors.ITmfTraceEditor;
int depth = entry.getStackLevel();
return Integer.toString(depth);
} else if (columnIndex == 2 && entry.getFunctionName().length() > 0) {
- ITmfTimestamp ts = new TmfTimestamp(entry.getFunctionEntryTime(), ITmfTimestamp.NANOSECOND_SCALE);
+ ITmfTimestamp ts = TmfTimestamp.fromNanos(entry.getFunctionEntryTime());
return ts.toString();
} else if (columnIndex == 3 && entry.getFunctionName().length() > 0) {
- ITmfTimestamp ts = new TmfTimestamp(entry.getFunctionExitTime(), ITmfTimestamp.NANOSECOND_SCALE);
+ ITmfTimestamp ts = TmfTimestamp.fromNanos(entry.getFunctionExitTime());
return ts.toString();
} else if (columnIndex == 4 && entry.getFunctionName().length() > 0) {
ITmfTimestamp ts = new TmfTimestampDelta(entry.getFunctionExitTime() - entry.getFunctionEntryTime(), ITmfTimestamp.NANOSECOND_SCALE);
long spacingTime = (long) ((exitTime - entryTime) * SPACING_RATIO);
entryTime -= spacingTime;
exitTime += spacingTime;
- TmfTimeRange range = new TmfTimeRange(new TmfNanoTimestamp(entryTime), new TmfNanoTimestamp(exitTime));
+ TmfTimeRange range = new TmfTimeRange(TmfTimestamp.fromNanos(entryTime), TmfTimestamp.fromNanos(exitTime));
broadcast(new TmfWindowRangeUpdatedSignal(CallStackView.this, range));
getTimeGraphViewer().setStartFinishTime(entryTime, exitTime);
startZoomThread(entryTime, exitTime);
long spacingTime = (long) ((endTime - startTime) * SPACING_RATIO);
startTime -= spacingTime;
endTime += spacingTime;
- TmfTimeRange range = new TmfTimeRange(new TmfNanoTimestamp(startTime), new TmfNanoTimestamp(endTime));
+ TmfTimeRange range = new TmfTimeRange(TmfTimestamp.fromNanos(startTime), TmfTimestamp.fromNanos(endTime));
broadcast(new TmfWindowRangeUpdatedSignal(CallStackView.this, range));
getTimeGraphViewer().setStartFinishTime(startTime, endTime);
startZoomThread(startTime, endTime);
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
import org.eclipse.tracecompass.tmf.core.signal.TmfTimestampFormatUpdateSignal;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampDelta;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
import org.eclipse.tracecompass.tmf.ui.signal.TmfTimeViewAlignmentSignal;
import org.eclipse.tracecompass.tmf.ui.views.ITmfTimeAligned;
buffer.append(newLine);
}
buffer.append(NLS.bind(Messages.Histogram_bucketRangeToolTip,
- new TmfTimestamp(startTime, ITmfTimestamp.NANOSECOND_SCALE).toString(),
- new TmfTimestamp(endTime, ITmfTimestamp.NANOSECOND_SCALE).toString()));
+ TmfTimestamp.fromNanos(startTime).toString(),
+ TmfTimestamp.fromNanos(endTime).toString()));
buffer.append(newLine);
buffer.append(NLS.bind(Messages.Histogram_eventCountToolTip, nbEvents));
if (!HistogramScaledData.hideLostEvents) {
import org.eclipse.swt.widgets.Composite;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
import org.eclipse.tracecompass.tmf.core.signal.TmfTimestampFormatUpdateSignal;
-import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
@Override
public void setValue(long time) {
if (time != Long.MIN_VALUE) {
- super.setValue(time, new TmfTimestamp(time, ITmfTimestamp.NANOSECOND_SCALE).toString());
+ super.setValue(time, TmfTimestamp.fromNanos(time).toString());
} else {
super.setValue(time, ""); //$NON-NLS-1$
}
@Override
public void setValue(long time) {
if (time != Long.MIN_VALUE) {
- ITmfTimestamp ts = new TmfTimestamp(time, ITmfTimestamp.NANOSECOND_SCALE);
+ ITmfTimestamp ts = TmfTimestamp.fromNanos(time);
super.setValue(time, ts.toString(TmfTimestampFormat.getDefaulIntervalFormat()));
} else {
super.setValue(time, ""); //$NON-NLS-1$
*/
public TmfTimeRange getTimeRange() {
return new TmfTimeRange(
- new TmfTimestamp(fWindowStartTime, ITmfTimestamp.NANOSECOND_SCALE),
- new TmfTimestamp(fWindowEndTime, ITmfTimestamp.NANOSECOND_SCALE));
+ TmfTimestamp.fromNanos(fWindowStartTime),
+ TmfTimestamp.fromNanos(fWindowEndTime));
}
/**
*/
void updateSelectionTime(long beginTime, long endTime) {
updateDisplayedSelectionTime(beginTime, endTime);
- TmfTimestamp beginTs = new TmfTimestamp(beginTime, ITmfTimestamp.NANOSECOND_SCALE);
- TmfTimestamp endTs = new TmfTimestamp(endTime, ITmfTimestamp.NANOSECOND_SCALE);
+ ITmfTimestamp beginTs = TmfTimestamp.fromNanos(beginTime);
+ ITmfTimestamp endTs = TmfTimestamp.fromNanos(endTime);
TmfSelectionRangeUpdatedSignal signal = new TmfSelectionRangeUpdatedSignal(this, beginTs, endTs);
fTimeSyncThrottle.queue(signal);
}
if (fTrace != null) {
// Build the new time range; keep the current time
TmfTimeRange timeRange = new TmfTimeRange(
- new TmfTimestamp(startTime, ITmfTimestamp.NANOSECOND_SCALE),
- new TmfTimestamp(endTime, ITmfTimestamp.NANOSECOND_SCALE));
+ TmfTimestamp.fromNanos(startTime),
+ TmfTimestamp.fromNanos(endTime));
fTimeSpanControl.setValue(endTime - startTime);
updateDisplayedTimeRange(startTime, endTime);
if ((fTimeRangeRequest != null) && !fTimeRangeRequest.isCompleted()) {
fTimeRangeRequest.cancel();
}
- TmfTimestamp startTS = new TmfTimestamp(startTime, ITmfTimestamp.NANOSECOND_SCALE);
- TmfTimestamp endTS = new TmfTimestamp(endTime, ITmfTimestamp.NANOSECOND_SCALE);
+ ITmfTimestamp startTS = TmfTimestamp.fromNanos(startTime);
+ ITmfTimestamp endTS = TmfTimestamp.fromNanos(endTime);
TmfTimeRange timeRange = new TmfTimeRange(startTS, endTS);
fTimeRangeHistogram.clear();
!interval.getStateValue().isNull();
stateEntry = new StateEntry(ss.getAttributeName(quark), quark, ss.getFullAttributePath(quark),
interval.getStateValue(),
- new TmfTimestamp(interval.getStartTime(), ITmfTimestamp.NANOSECOND_SCALE),
- new TmfTimestamp(interval.getEndTime(), ITmfTimestamp.NANOSECOND_SCALE),
+ TmfTimestamp.fromNanos(interval.getStartTime()),
+ TmfTimestamp.fromNanos(interval.getEndTime()),
modified);
// update children first to know if parent is really needed
}
} else {
stateEntry.update(interval.getStateValue(),
- new TmfTimestamp(interval.getStartTime(), ITmfTimestamp.NANOSECOND_SCALE),
- new TmfTimestamp(interval.getEndTime(), ITmfTimestamp.NANOSECOND_SCALE));
+ TmfTimestamp.fromNanos(interval.getStartTime()),
+ TmfTimestamp.fromNanos(interval.getEndTime()));
// update children recursively
updateStateEntries(ss, fullState, stateEntry, quark, timestamp);
private final int fQuark;
private final String fFullPath;
- private @NonNull TmfTimestamp fStart;
- private @NonNull TmfTimestamp fEnd;
+ private @NonNull ITmfTimestamp fStart;
+ private @NonNull ITmfTimestamp fEnd;
private ITmfStateValue fValue;
private boolean fModified;
private boolean fOutOfRange = false;
- public StateEntry(String name, int quark, String fullPath, ITmfStateValue value, @NonNull TmfTimestamp start, @NonNull TmfTimestamp end, boolean modified) {
+ public StateEntry(String name, int quark, String fullPath, ITmfStateValue value, @NonNull ITmfTimestamp start, @NonNull ITmfTimestamp end, boolean modified) {
super(name);
fQuark = quark;
fFullPath = fullPath;
return fModified;
}
- public void update(ITmfStateValue value, @NonNull TmfTimestamp start, @NonNull TmfTimestamp end) {
+ public void update(ITmfStateValue value, @NonNull ITmfTimestamp start, @NonNull ITmfTimestamp end) {
fModified = false;
fOutOfRange = false;
if (!start.equals(fStart)) {
/** TimeChartView's ID */
public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.timechart"; //$NON-NLS-1$
- private static final int TIMESTAMP_SCALE = -9;
-
private final int fDisplayWidth;
private TimeGraphViewer fViewer;
private final List<TimeChartAnalysisEntry> fTimeAnalysisEntries = new ArrayList<>();
fStartTime = event.getStartTime();
fStopTime = event.getEndTime();
itemize(fStartTime, fStopTime);
- final ITmfTimestamp startTimestamp = new TmfTimestamp(event.getStartTime(), ITmfTimestamp.NANOSECOND_SCALE);
- final ITmfTimestamp endTimestamp = new TmfTimestamp(event.getEndTime(), ITmfTimestamp.NANOSECOND_SCALE);
+ final ITmfTimestamp startTimestamp = TmfTimestamp.fromNanos(event.getStartTime());
+ final ITmfTimestamp endTimestamp = TmfTimestamp.fromNanos(event.getEndTime());
TmfTimeRange range = new TmfTimeRange(startTimestamp, endTimestamp);
broadcast(new TmfWindowRangeUpdatedSignal(this, range));
}
@Override
public void timeSelected(TimeGraphTimeEvent event) {
- broadcast(new TmfSelectionRangeUpdatedSignal(this, new TmfTimestamp(event.getBeginTime(), TIMESTAMP_SCALE), new TmfTimestamp(event.getEndTime(), TIMESTAMP_SCALE)));
+ broadcast(new TmfSelectionRangeUpdatedSignal(this, TmfTimestamp.fromNanos(event.getBeginTime()), TmfTimestamp.fromNanos(event.getEndTime())));
}
@Override
final long beginTime = signal.getBeginTime().toNanos();
final long endTime = signal.getEndTime().toNanos();
-
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal;
import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceAdapterManager;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext;
public void timeRangeUpdated(TimeGraphRangeUpdateEvent event) {
final long startTime = event.getStartTime();
final long endTime = event.getEndTime();
- TmfTimeRange range = new TmfTimeRange(new TmfNanoTimestamp(startTime), new TmfNanoTimestamp(endTime));
+ TmfTimeRange range = new TmfTimeRange(TmfTimestamp.fromNanos(startTime), TmfTimestamp.fromNanos(endTime));
broadcast(new TmfWindowRangeUpdatedSignal(AbstractTimeGraphView.this, range));
startZoomThread(startTime, endTime);
}
fTimeGraphWrapper.getTimeGraphViewer().addTimeListener(new ITimeGraphTimeListener() {
@Override
public void timeSelected(TimeGraphTimeEvent event) {
- TmfNanoTimestamp startTime = new TmfNanoTimestamp(event.getBeginTime());
- TmfNanoTimestamp endTime = new TmfNanoTimestamp(event.getEndTime());
+ ITmfTimestamp startTime = TmfTimestamp.fromNanos(event.getBeginTime());
+ ITmfTimestamp endTime = TmfTimestamp.fromNanos(event.getEndTime());
broadcast(new TmfSelectionRangeUpdatedSignal(AbstractTimeGraphView.this, startTime, endTime));
}
});
marker.setAttribute(ITmfMarker.MARKER_DURATION, Long.toString(bookmark.getDuration()));
marker.setAttribute(IMarker.LOCATION,
NLS.bind(org.eclipse.tracecompass.internal.tmf.ui.Messages.TmfMarker_LocationTimeRange,
- new TmfNanoTimestamp(bookmark.getTime()),
- new TmfNanoTimestamp(bookmark.getTime() + bookmark.getDuration())));
+ TmfTimestamp.fromNanos(bookmark.getTime()),
+ TmfTimestamp.fromNanos(bookmark.getTime() + bookmark.getDuration())));
} else {
marker.setAttribute(IMarker.LOCATION,
NLS.bind(org.eclipse.tracecompass.internal.tmf.ui.Messages.TmfMarker_LocationTime,
- new TmfNanoTimestamp(bookmark.getTime())));
+ TmfTimestamp.fromNanos(bookmark.getTime())));
}
marker.setAttribute(ITmfMarker.MARKER_COLOR, bookmark.getColor().toString());
}
/**
* The minimum time delta.
*/
- private ITmfTimestamp fMinTime = new TmfTimestamp();
+ private ITmfTimestamp fMinTime = TmfTimestamp.fromSeconds(0);
/**
* The maximum time delta.
*/
- private ITmfTimestamp fMaxTime = new TmfTimestamp();
+ private ITmfTimestamp fMaxTime = TmfTimestamp.fromSeconds(0);
/**
* The current zoom value.
*/
/**
* The time when the message begin
*/
- private ITmfTimestamp fEndTime = new TmfTimestamp();
+ private ITmfTimestamp fEndTime = TmfTimestamp.fromSeconds(0);
/**
* The time when the message end
*/
- private ITmfTimestamp fStartTime = new TmfTimestamp();
+ private ITmfTimestamp fStartTime = TmfTimestamp.fromSeconds(0);
/**
* The associated message.
*/
/**
* Contains the max elapsed time between two consecutive messages in the whole frame
*/
- private ITmfTimestamp fMaxTime = new TmfTimestamp(0);
+ private ITmfTimestamp fMaxTime = TmfTimestamp.fromSeconds(0);
/**
* Contains the min elapsed time between two consecutive messages in the whole frame
*/
- private ITmfTimestamp fMinTime = new TmfTimestamp(0);
+ private ITmfTimestamp fMinTime = TmfTimestamp.fromSeconds(0);
/**
* Indicate if the min and max elapsed time between two consecutive messages in the whole frame need to be computed
*/
/**
* The minimum time between messages of the sequence diagram frame.
*/
- private ITmfTimestamp fMinSDTime = new TmfTimestamp();
+ private ITmfTimestamp fMinSDTime = TmfTimestamp.fromSeconds(0);
/**
* The maximum time between messages of the sequence diagram frame.
*/
- private ITmfTimestamp fMaxSDTime = new TmfTimestamp();
+ private ITmfTimestamp fMaxSDTime = TmfTimestamp.fromSeconds(0);
/**
* Flag to indicate that initial minimum has to be computed.
*/
if (fComputeMinMax) {
fMinTime = delta;
if (fMinTime.compareTo(TmfTimestamp.ZERO) < 0) {
- fMinTime = new TmfTimestamp(0, m1.getTime().getScale());
+ fMinTime = TmfTimestamp.create(0, m1.getTime().getScale());
}
fMaxTime = fMinTime;
setComputeMinMax(false);
/**
* The time when the message occurs
*/
- private ITmfTimestamp fEventTime = new TmfTimestamp();
+ private ITmfTimestamp fEventTime = TmfTimestamp.fromSeconds(0);
/**
* Flag whether the message has time information available or not
*/
max = Long.parseLong(fMaxText.getText());
scale = Integer.parseInt(fScaleText.getText());
- fSdWidget.getFrame().setMax(new TmfTimestamp(max, scale));
- fSdWidget.getFrame().setMin(new TmfTimestamp(min, scale));
+ fSdWidget.getFrame().setMax(TmfTimestamp.create(max, scale));
+ fSdWidget.getFrame().setMin(TmfTimestamp.create(min, scale));
fSdWidget.redraw();
try {
TmfTimeRange currentRange = TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange();
long offset = fTrace == null ? 0 : currentRange.getEndTime().getDelta(currentRange.getStartTime()).toNanos();
- TmfTimestamp initialEndOfWindow = new TmfTimestamp(startTime.getValue() + offset, startTime.getScale());
+ ITmfTimestamp initialEndOfWindow = TmfTimestamp.create(startTime.getValue() + offset, startTime.getScale());
return new TmfTimeRange(startTime, initialEndOfWindow);
}
finally {