aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Wininger2014-02-06 13:58:57 (EST)
committerGenevieve Bastien2014-02-06 15:24:45 (EST)
commit66ee243eaaa6ba129262ad05875f83b81fa2527f (patch)
tree6939f5e11fc53b22149adb400a84a1ecf823625e
parent06de6245ffb6065f8e7417083595b3c364570f23 (diff)
downloadorg.eclipse.linuxtools-66ee243eaaa6ba129262ad05875f83b81fa2527f.zip
org.eclipse.linuxtools-66ee243eaaa6ba129262ad05875f83b81fa2527f.tar.gz
org.eclipse.linuxtools-66ee243eaaa6ba129262ad05875f83b81fa2527f.tar.bz2
tmf : fix for CtfIterator getCurrentEvent()refs/changes/80/21480/5
This function is very costly and is called 3 times per event. The previous CurrentEvent is cached to accelerate the process of building the state system Benchmark for the TMF sample trace (13.4 Mo with 697343 events) : Before : Build of the state system : 8.896 s Call of createEvent function : 2 091 982 After : Build of the state system : 6.829 s Call of createEvent function : 697 343 Benckmark with a 100Mo kernel trace : Before : 48.1s After : 38.0s Possible gain of the state system building time : 23 % Change-Id: Ibee6509dc378503ad672ca038b3ab17273a11966 Signed-off-by: Florian Wininger <florian.wininger@polymtl.ca> Reviewed-on: https://git.eclipse.org/r/21480 Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net> IP-Clean: Genevieve Bastien <gbastien+lttng@versatic.net> Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net> Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com> IP-Clean: Matthew Khouzam <matthew.khouzam@ericsson.com> Tested-by: Hudson CI
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java
index 135f1c1..1efa1c0 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
+ * Copyright (c) 2012, 2014 Ericsson, École Polytechnique de Montréal
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0 which
@@ -8,6 +8,7 @@
*
* Contributors:
* Matthew Khouzam - Initial API and implementation
+ * Florian Wininger - Performance improvements
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.ctfadaptor;
@@ -38,6 +39,9 @@ public class CtfIterator extends CTFTraceReader
private CtfLocation fCurLocation;
private long fCurRank;
+ private CtfLocation fPreviousLocation;
+ private CtfTmfEvent fPreviousEvent;
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
@@ -117,11 +121,15 @@ public class CtfIterator extends CTFTraceReader
*
* @return CtfTmfEvent The current event
*/
- public CtfTmfEvent getCurrentEvent() {
+ public synchronized CtfTmfEvent getCurrentEvent() {
final StreamInputReader top = super.getPrio().peek();
if (top != null) {
- return CtfTmfEventFactory.createEvent(top.getCurrentEvent(),
- top.getFilename(), fTrace);
+ if (!fCurLocation.equals(fPreviousLocation)) {
+ fPreviousLocation = fCurLocation;
+ fPreviousEvent = CtfTmfEventFactory.createEvent(top.getCurrentEvent(),
+ top.getFilename(), fTrace);
+ }
+ return fPreviousEvent;
}
return null;
}