X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=org.eclipse.linuxtools.tmf%2Fsrc%2Forg%2Feclipse%2Flinuxtools%2Ftmf%2Fevent%2FTmfTimestamp.java;h=63168db9afa698226967101ed18b6f248ba3106f;hb=7300515205f464a903291c794427560f1ad5a5ed;hp=b786e3dd309d0e0de640a17e7a05c17864a54c6c;hpb=316df2f6955654c21498b75791ac54bc1c91132f;p=deliverable%2Ftracecompass.git diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfTimestamp.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfTimestamp.java index b786e3dd30..63168db9af 100644 --- a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfTimestamp.java +++ b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfTimestamp.java @@ -256,6 +256,23 @@ public class TmfTimestamp implements Cloneable { return ts2.fValue - ts1.fValue; } + /** + * Compute the delta between two timestamps (adjusted to scale of current timestamp). + * + * @param reference the reference timestamp to synchronize with + * @return the delta timestamp + * @throws ArithmeticException + */ + public TmfTimestamp getDelta(TmfTimestamp other) throws ArithmeticException { + TmfTimestamp newSecond = other; + if ((fScale != other.fScale) || (fPrecision != other.fPrecision)) { + newSecond = other.synchronize(0, fScale); + } + return new TmfTimestamp(fValue - newSecond.fValue, + fScale, + newSecond.fPrecision > fPrecision ? newSecond.fPrecision : fPrecision); + } + /** * Compare with another timestamp *