}
// Path of the trace
- public static final String TRACE_PATH = "../org.eclipse.linuxtools.ctf.core.tests/Tests/traces/trace20m1";
+ public static final String TRACE_PATH = "../org.eclipse.linuxtools.ctf.core.tests/traces/kernel";
// *** Change this to run several time over the same trace
public static final int NB_OF_PASS = 100;
// Create a new time range from -infinity to +infinity
// That way, we will get "everything" in the trace
- final CtfTmfTimestamp ts1 = new CtfTmfTimestamp(Long.MIN_VALUE,
- (CtfTmfTrace) traces[0]);
- final CtfTmfTimestamp ts2 = new CtfTmfTimestamp(Long.MAX_VALUE,
- (CtfTmfTrace) traces[0]);
+ final CtfTmfTimestamp ts1 = new CtfTmfTimestamp(Long.MIN_VALUE);
+ final CtfTmfTimestamp ts2 = new CtfTmfTimestamp(Long.MAX_VALUE);
final TmfTimeRange tmpRange = new TmfTimeRange(ts1, ts2);
// We will issue a request for each "pass".
nbEvent = 0;
prev = next;
benchs.add(val);
- if (benchs.size() == NB_OF_PASS)
+ if (benchs.size() == NB_OF_PASS) {
try {
System.out.println("Nb events : " + nbEvent2);
- for (final double value : benchs)
+ for (final double value : benchs) {
System.out.print(value + ", ");
+ }
fExperiment.sendRequest(null);
} catch (final Exception e) {
}
+ }
}
@Override
+/*******************************************************************************
+ * Copyright (c) 2012 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: Matthew Khouzam - Initial API and implementation
+ *******************************************************************************/
+
package org.eclipse.linuxtools.tmf.core.ctfadaptor;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
+import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
public class CtfTmfTimestamp extends TmfTimestamp {
- final private CtfTmfTrace fTrace;
+ public enum TimestampType {
+ FULL_DATE, DAY, NANOS, SECONDS
+ }
+
+ private TimestampType type;
- public CtfTmfTimestamp(long timestamp, CtfTmfTrace trace) {
- fTrace = trace;
+ public CtfTmfTimestamp(long timestamp) {
setValue(timestamp, -9, 0);
+ type = TimestampType.DAY;
}
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = (prime * result) + ((fTrace == null) ? 0 : fTrace.hashCode());
- return result;
+ public void setType(TimestampType value) {
+ type = value;
+ }
+
+ public TimestampType getType() {
+ return type;
}
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.linuxtools.tmf.core.event.TmfTimestamp#getDelta(org.eclipse
+ * .linuxtools.tmf.core.event.ITmfTimestamp)
*/
@Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof CtfTmfTimestamp)) {
- return false;
+ public ITmfTimestamp getDelta(ITmfTimestamp ts) {
+ TmfTimestamp parent = (TmfTimestamp) super.getDelta(ts);
+ long value = parent.getValue();
+ long exp = parent.getScale();
+ long diff = exp + 9;
+ for (int i = 0; i < diff; i++) {
+ value *= 10;
}
- CtfTmfTimestamp other = (CtfTmfTimestamp) obj;
- if (fTrace == null) {
- if (other.fTrace != null) {
- return false;
- }
- } else if (!fTrace.equals(other.fTrace)) {
- return false;
+ CtfTmfTimestamp retVal = new CtfTmfTimestamp(value);
+ if (value > 100000000) {
+ retVal.type = TimestampType.SECONDS;
+ } else {
+ retVal.type = TimestampType.NANOS;
}
- return true;
+ return retVal;
}
/*
*/
@Override
public String toString() {
+ switch (type) {
+ case DAY: {
+ return dateToString();
+ }
+ case FULL_DATE: {
+ return toFullDateString();
+ }
+ case NANOS: {
+ return nanoToString();
+ }
+ case SECONDS:{
+ return secondsToString();
+ }
+ }
+ return super.toString();
+ }
+
+ private String secondsToString() {
+ double timestamp = getValue();
+ timestamp /= 1000000000;
+ StringBuilder retVal = new StringBuilder();
+ retVal.append(timestamp);
+ retVal.append(" s"); //$NON-NLS-1$
+ return retVal.toString();
+ }
+
+ private String nanoToString() {
+ final long timestamp = getValue();
+ StringBuilder retVal = new StringBuilder();
+ retVal.append(timestamp);
+ retVal.append(" ns"); //$NON-NLS-1$
+ return retVal.toString();
+ }
+
+ private String dateToString() {
final long timestamp = getValue();
final Date d = new Date(timestamp / 1000000);
final DateFormat df = new SimpleDateFormat("HH:mm:ss."); //$NON-NLS-1$
return output.toString();
}
- public String toFullDateString(){
+ private String toFullDateString() {
final long timestamp = getValue();
final Date d = new Date(timestamp / 1000000);
final DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss."); //$NON-NLS-1$