diff options
author | Francois Chouinard | 2010-10-29 18:51:58 +0000 |
---|---|---|
committer | Francois Chouinard | 2010-10-29 18:51:58 +0000 |
commit | 8a05c8b0d567ff7a79dccee7efcaebe0453d97d0 (patch) | |
tree | 9a12f1aa6f9e4928feb0784407daf13155065b44 /lttng/org.eclipse.linuxtools.lttng.jni | |
parent | 67e8309b13c5586bcb1e8f710400c35b51cc0967 (diff) | |
download | org.eclipse.linuxtools-8a05c8b0d567ff7a79dccee7efcaebe0453d97d0.tar.gz org.eclipse.linuxtools-8a05c8b0d567ff7a79dccee7efcaebe0453d97d0.tar.xz org.eclipse.linuxtools-8a05c8b0d567ff7a79dccee7efcaebe0453d97d0.zip |
2010-10-29 Francois Chouinard <fchouinard@gmail.com> Contribution for Bug325661
* src/org/eclipse/linuxtools/lttng/event/LttngEventContent.java (getFields): Cosmetic change
* src/org/eclipse/linuxtools/lttng/trace/LTTngExperiment.java (getNextEvent): Oprimization when only 1 trace
* src/org/eclipse/linuxtools/lttng/trace/LTTngTrace.java: New hshing algorithm
* src/org/eclipse/linuxtools/lttng/jni/common/JniTime.java (equals): Optimization
* src/org/eclipse/linuxtools/lttng/jni/JniEvent.java (equals): Optimization
(compareTo): Optimization
* src/org/eclipse/linuxtools/lttng/jni/JniTrace.java (readNextEvent): Optimization
* src/org/eclipse/linuxtools/lttng/ui/views/histogram/ParentHistogramCanvasPaintListener.java (paintControl): Temporary refresh fix
* src/org/eclipse/linuxtools/tmf/experiment/TmfExperiment.java (getNextEvent): Removed an unnecessary clone() operation
Diffstat (limited to 'lttng/org.eclipse.linuxtools.lttng.jni')
4 files changed, 50 insertions, 32 deletions
diff --git a/lttng/org.eclipse.linuxtools.lttng.jni/ChangeLog b/lttng/org.eclipse.linuxtools.lttng.jni/ChangeLog new file mode 100644 index 0000000000..5e713b7097 --- /dev/null +++ b/lttng/org.eclipse.linuxtools.lttng.jni/ChangeLog @@ -0,0 +1,6 @@ +2010-10-29 Francois Chouinard <fchouinard@gmail.com> + + * src/org/eclipse/linuxtools/lttng/jni/common/JniTime.java (equals): Optimization + * src/org/eclipse/linuxtools/lttng/jni/JniEvent.java (equals): Optimization + (compareTo): Optimization + * src/org/eclipse/linuxtools/lttng/jni/JniTrace.java (readNextEvent): Optimization diff --git a/lttng/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniEvent.java b/lttng/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniEvent.java index d6acbdeac6..7350229bb2 100644 --- a/lttng/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniEvent.java +++ b/lttng/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniEvent.java @@ -405,6 +405,14 @@ public abstract class JniEvent extends Jni_C_Common implements Comparable<JniEve return parentTracefile; } + public boolean equals(JniEvent other) { + if (other != null) { + return (this.getEventTime().equals(other.getEventTime()) + && this.parentTracefile.equals(other.parentTracefile)); + } + return false; + } + /** * Compare fonction for JNIEvent.<p> * <p> @@ -414,25 +422,24 @@ public abstract class JniEvent extends Jni_C_Common implements Comparable<JniEve * @return -1 if given event happens before, 0 if equal, 1 if passed event happens after. */ @Override - public int compareTo(JniEvent rightEvent ){ - - // Note : this = left hand operand - - // By default, we consider the current event to be older. - int eventComparaison = -1; - - // Test against null before performing anything - if ( rightEvent != null ) { - // Compare the timestamp first - eventComparaison = this.getEventTime().compareTo( rightEvent.getEventTime() ); - - // If timestamp is equal, compare the parent tracefile ("event type") - if ( (eventComparaison == 0) && ( !this.parentTracefile.equals(rightEvent.parentTracefile)) ) { - eventComparaison = 1; - } - } - return eventComparaison; - } + public int compareTo(JniEvent other) { + + // By default, we consider the current event to be older. + int eventComparaison = -1; + + // Test against null before performing anything + if (other != null) { + // Compare the timestamp first + eventComparaison = this.getEventTime().compareTo(other.getEventTime()); + + // If timestamp is equal, compare the parent trace file ("event type") + if ((eventComparaison == 0) + && (!this.parentTracefile.equals(other.parentTracefile))) { + eventComparaison = 1; + } + } + return eventComparaison; + } /** * Print information for this event. diff --git a/lttng/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniTrace.java b/lttng/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniTrace.java index 9387662a37..9939fb3f76 100644 --- a/lttng/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniTrace.java +++ b/lttng/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniTrace.java @@ -454,7 +454,8 @@ public abstract class JniTrace extends Jni_C_Common { // Otherwise, we need to make sure the timestamp of the event we got is not the same as the last "NextEvent" we requested // NOTE : JniEvent.compareTo() compare by timestamp AND type, as 2 events of different type could have the same timestamp. - if ( tmpEvent.compareTo(currentEvent) == 0 ) { +// if( currentEvent != null ){ + if (tmpEvent.equals(currentEvent)) { // Remove the event on top as it is the same currentEventTimestamp eventsHeap.poll(); diff --git a/lttng/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/common/JniTime.java b/lttng/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/common/JniTime.java index 40b60104ce..dba1bfd614 100644 --- a/lttng/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/common/JniTime.java +++ b/lttng/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/common/JniTime.java @@ -159,24 +159,28 @@ public class JniTime extends Jni_C_Constant implements Comparable<JniTime> } /** - * Overrided equals for JniTime type + * faster equals since it is called very often + * @param other the object to the right of this + * @return true if the times are the same, false otherwise. + */ + public boolean equals(JniTime other) { + return ((other != null) && (this.time == other.time)); + } + + /** + * Overridden equals for JniTime type * * @param The object we want to compare too * * @return true if the time is the same, false otherwise. */ @Override - public boolean equals(Object obj) { - boolean returnedValue = false; - - if ( obj instanceof JniTime ) { - if ( ((JniTime)obj).time == this.time ) { - returnedValue = true; - } - } - - return returnedValue; - } + public boolean equals(Object obj) { + if (obj instanceof JniTime) { + return (((JniTime) obj).time == this.time); + } + return false; + } /** * Overridden hash code for JniTime type |