From: Matthew Khouzam Date: Thu, 12 Jul 2012 13:59:41 +0000 (-0400) Subject: Fix benchmark to use ctftmflightweightcontexts X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=156a3e3aeca4b03b77991307a5887013635d1264;p=deliverable%2Ftracecompass.git Fix benchmark to use ctftmflightweightcontexts Change-Id: I64ff93f6564aec865370d4f166f7dcadf58a3295 Signed-off-by: Matthew Khouzam Reviewed-on: https://git.eclipse.org/r/6769 Tested-by: Hudson CI Reviewed-by: Patrick Tasse IP-Clean: Patrick Tasse Reviewed-by: Alexandre Montplaisir IP-Clean: Alexandre Montplaisir Tested-by: Alexandre Montplaisir --- diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/headless/Benchmark.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/headless/Benchmark.java index 7c92ca4d09..dca3716795 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/headless/Benchmark.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/headless/Benchmark.java @@ -14,8 +14,8 @@ package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor.headless; import java.util.Vector; -import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfIterator; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent; +import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfLightweightContext; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace; import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; @@ -38,11 +38,6 @@ public class Benchmark { // Change this to enable text output final boolean USE_TEXT = true; -// try { -// System.in.read(); -// } catch (final IOException e1) { -// e1.printStackTrace(); -// } // Work variables Long nbEvent = 0L; final Vector benchs = new Vector(); @@ -60,7 +55,7 @@ public class Benchmark { start = System.nanoTime(); if (nbEvent != -1) { - final CtfIterator traceReader = (CtfIterator) trace.seekEvent(0); + final CtfTmfLightweightContext traceReader = (CtfTmfLightweightContext) trace.seekEvent(0); start = System.nanoTime(); CtfTmfEvent current = traceReader.getCurrentEvent(); @@ -68,11 +63,15 @@ public class Benchmark { nbEvent++; if (USE_TEXT) { - System.out.println("Event " + traceReader.getRank() + " Time " //$NON-NLS-1$ //$NON-NLS-2$ + System.out.println("Event " + nbEvent + " Time " //$NON-NLS-1$ //$NON-NLS-2$ + current.getTimestamp().toString() + " type " + current.getEventName() //$NON-NLS-1$ + " on CPU " + current.getSource() + " " + current.getContent().toString()) ; //$NON-NLS-1$ //$NON-NLS-2$ } - traceReader.advance(); + // advance the trace to the next event. + boolean hasMore = traceReader.advance(); + if( hasMore ){ + // you can know the trace has more events. + } current = traceReader.getCurrentEvent(); } } @@ -95,16 +94,4 @@ public class Benchmark { } -// /** -// * @param timestamp -// * the timestamp in UTC to convert to nanoseconds. -// * @return formatted string. -// */ -// private static String formatDate(final long timestamp) { -// final Date d = new Date(timestamp / 1000000); -// final DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss."); //$NON-NLS-1$ -// final String output = df.format(d) + (timestamp % 1000000000); -// return output; -// } - }