From dad5bdc62af79bbf033f289556d0d8716e66fe44 Mon Sep 17 00:00:00 2001 From: Matthew Khouzam Date: Tue, 10 Apr 2012 10:27:14 -0400 Subject: add benchmarks Conflicts: lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/headless/ReadTrace.java --- .../ctf/core/tests/headless/ReadTrace.java | 59 ++++++++++++++++++++++ .../core/tests/ctfadaptor/headless/Benchmark.java | 15 +++--- 2 files changed, 66 insertions(+), 8 deletions(-) diff --git a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/headless/ReadTrace.java b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/headless/ReadTrace.java index d3977e2fc5..bd13a1f90c 100644 --- a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/headless/ReadTrace.java +++ b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/headless/ReadTrace.java @@ -93,6 +93,65 @@ public class ReadTrace { System.out.print(", "); } + try { + testSeekIndex(trace); + } catch (CTFReaderException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + /** + * @return + */ + private static long getTimestamp(CTFTraceReader fixture) { + if (fixture.getCurrentEventDef() != null) { + return fixture.getCurrentEventDef().timestamp; + } + return Long.MIN_VALUE; + } + + public static void testSeekIndex(CTFTrace trace) throws CTFReaderException { + CTFTraceReader fixture = new CTFTraceReader(trace); + long rank = 300000L; + long timeRank = 4281275394331L; + long nearEnd = 4287422858132L; + long seekTime_0; + long seekIndex_0 = 0; + long seekNext_300000 = 0; + long seekIndex_300000 = 0; + long seekTime_300000 = 0; + String cr = "\n"; //$NON-NLS-1$ + fixture.seek(0); + for (int i = 0; i < 100; i++) { + fixture.advance(); + } + + fixture.seek(nearEnd); + /* + * we need to read the trace before seeking + */ + fixture.seek(0); + seekTime_0 = getTimestamp(fixture); + for (int i = 0; i < rank; i++) { + fixture.advance(); + } + seekNext_300000 = getTimestamp(fixture); + fixture.seek(timeRank); + seekTime_300000 = getTimestamp(fixture); + fixture.seekIndex(0); + seekIndex_0 = getTimestamp(fixture); + + fixture.seekIndex(rank); + seekIndex_300000 = getTimestamp(fixture); + System.out.print(cr); + System.out.println("seek(0) " + seekTime_0 + cr + //$NON-NLS-1$ + "seekIndex(0) " + seekIndex_0 + cr + //$NON-NLS-1$ + "Next(300000) " + seekNext_300000 + cr + //$NON-NLS-1$ + "seek(time(300000)) " + seekTime_300000 + cr + //$NON-NLS-1$ + "seekIndex(300000) " + seekIndex_300000 //$NON-NLS-1$ + ); } /** diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/headless/Benchmark.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/headless/Benchmark.java index 84a048fd89..a5d214b0f8 100644 --- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/headless/Benchmark.java +++ b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/headless/Benchmark.java @@ -12,7 +12,6 @@ package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor.headless; import java.io.FileNotFoundException; -import java.io.IOException; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; @@ -34,13 +33,13 @@ public class Benchmark { // Change this to enable text output final boolean USE_TEXT = false; - - try { - System.in.read(); - } catch (IOException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } +// +// try { +// System.in.read(); +// } catch (IOException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } // Work variables Long nbEvent = 0L; Vector benchs = new Vector(); -- cgit v1.2.3