From: Matthew Khouzam Date: Mon, 4 Jun 2012 20:50:55 +0000 (-0400) Subject: Improve performance of seeks by a factor of approximately 8000. X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=0c59c1a6d0bdc5a942f070477303de0b7b3c45c7;p=deliverable%2Ftracecompass.git Improve performance of seeks by a factor of approximately 8000. Signed-off-by: Matthew Khouzam --- diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputReader.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputReader.java index 00842e8f7b..8165242854 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputReader.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputReader.java @@ -57,8 +57,6 @@ public class StreamInputReader { private final long prevIndex; - private final boolean isthisthefirsttimewerereadingthisgivenstream; - // ------------------------------------------------------------------------ // Constructors // ------------------------------------------------------------------------ @@ -72,7 +70,6 @@ public class StreamInputReader { public StreamInputReader(StreamInput streamInput) { this.streamInput = streamInput; this.packetReader = new StreamInputPacketReader(this); - this.isthisthefirsttimewerereadingthisgivenstream = true; /* * Get the iterator on the packet index. */ @@ -134,7 +131,6 @@ public class StreamInputReader { */ public boolean readNextEvent() { - /* * Change packet if needed */ @@ -163,8 +159,6 @@ public class StreamInputReader { } return true; } - final StreamInputPacketIndexEntry currentPacket = this - .getPacketReader().getCurrentPacket(); this.setCurrentEvent(null); return false; } @@ -219,6 +213,19 @@ public class StreamInputReader { */ goToNextPacket(); + /* + * index up to the desired timestamp. + */ + while ((this.packetReader.getCurrentPacket() != null) + && (this.packetReader.getCurrentPacket().getTimestampEnd() < timestamp)) { + try { + this.streamInput.addPacketHeaderIndex(); + goToNextPacket(); + } catch (CTFReaderException e) { + // do nothing here + } + } + /* * Advance until A. we reached the end of the trace file (which means * the given timestamp is after the last event), or B. we found the