summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorMathieu Denis2012-08-23 16:56:19 (EDT)
committer Alexandre Montplaisir2012-08-24 15:53:27 (EDT)
commit5fca88a64e6717627424e8882e2228c28a32a48d (patch)
treee73fa8fd7cf223c02d901bbc92e98e9d5dff49f2
parent81bd680a9b4d080f11b46385e5166ca5a9717103 (diff)
downloadorg.eclipse.linuxtools-5fca88a64e6717627424e8882e2228c28a32a48d.zip
org.eclipse.linuxtools-5fca88a64e6717627424e8882e2228c28a32a48d.tar.gz
org.eclipse.linuxtools-5fca88a64e6717627424e8882e2228c28a32a48d.tar.bz2
tmf: Complete the statistics API
There were missing methods and fields in the statistics API to make it logically complete. Change-Id: I9d5078d1ed3f75e358c3b840cb1bf213d53caf6a Signed-off-by: Mathieu Denis <mathieu.denis@polymtl.ca> Reviewed-on: https://git.eclipse.org/r/7383 Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im> IP-Clean: Alexandre Montplaisir <alexmonthy@voxpopuli.im> Tested-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im> Reviewed-by: Bernd Hufmann <bhufmann@gmail.com> IP-Clean: Bernd Hufmann <bhufmann@gmail.com> Tested-by: Bernd Hufmann <bhufmann@gmail.com>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/TmfStatisticsViewer.java10
-rwxr-xr-xlttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/AbsTmfStatisticsTree.java40
-rwxr-xr-xlttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfBaseStatisticsTree.java25
-rwxr-xr-xlttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfStatisticsTreeNode.java13
-rwxr-xr-xlttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsView.java24
5 files changed, 92 insertions, 20 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/TmfStatisticsViewer.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/TmfStatisticsViewer.java
index d15f0f2..40ba29a 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/TmfStatisticsViewer.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/TmfStatisticsViewer.java
@@ -127,6 +127,11 @@ public class TmfStatisticsViewer extends TmfViewer {
*/
protected final Object fStatisticsRangeUpdateSyncObj = new Object();
+ /*
+ * The trace that is displayed by this viewer
+ */
+ protected ITmfTrace fTrace;
+
/**
* Indicates to process all events
*/
@@ -143,11 +148,6 @@ public class TmfStatisticsViewer extends TmfViewer {
private int fInstanceNb;
/**
- * The trace that is displayed by this viewer
- */
- private ITmfTrace fTrace;
-
- /**
* Object to store the cursor while waiting for the experiment to load
*/
private Cursor fWaitCursor = null;
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/AbsTmfStatisticsTree.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/AbsTmfStatisticsTree.java
index b372a58..3a6cbc4 100755
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/AbsTmfStatisticsTree.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/AbsTmfStatisticsTree.java
@@ -151,30 +151,41 @@ public abstract class AbsTmfStatisticsTree {
}
/**
- * Increase any kind of counter.
- *
- * This method must be implemented by subclasses.
+ * Register an event and increase his value by <i>qty</i>
*
* @param event
* Current event.
* @param extraInfo
* Extra information to pass along with the event.
- * @param values
- * Values desired.
+ * @param qty
+ * The number of events that must be counted.
*/
- public abstract void increase(ITmfEvent event, ITmfExtraEventInfo extraInfo, int values);
+ public abstract void registerEvent(ITmfEvent event, ITmfExtraEventInfo extraInfo, int qty);
/**
* Register an event.
*
+ * @param event
+ * Current event.
+ * @param extraInfo
+ * Extra information to pass along with the event.
+ */
+ public abstract void registerEvent(ITmfEvent event, ITmfExtraEventInfo extraInfo);
+
+ /**
+ * Register an event within a time range and increase his value by qty
+ *
* This method must be implemented by subclasses.
*
* @param event
* Current event.
* @param extraInfo
* Extra information to pass along with the event.
+ * @param qty
+ * The number of events that must be counted.
+ * @since 2.0
*/
- public abstract void registerEvent(ITmfEvent event, ITmfExtraEventInfo extraInfo);
+ public abstract void registerEventInTimeRange(ITmfEvent event, ITmfExtraEventInfo extraInfo, int qty);
/**
* Register an event within a time range.
@@ -216,6 +227,21 @@ public abstract class AbsTmfStatisticsTree {
}
/**
+ * Reset the global value of a node.
+ *
+ * Works recursively.
+ *
+ * @param path
+ * Path to the node.
+ * @since 2.0
+ */
+ public void resetGlobalValue(final TmfFixedArray<String> path) {
+ for (TmfStatisticsTreeNode node : getChildren(path)) {
+ node.resetGlobalValue();
+ }
+ }
+
+ /**
* Reset the time range value of a node.
*
* Works recursively.
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfBaseStatisticsTree.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfBaseStatisticsTree.java
index 4df3f3f..a1f0348 100755
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfBaseStatisticsTree.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfBaseStatisticsTree.java
@@ -163,8 +163,16 @@ public class TmfBaseStatisticsTree extends AbsTmfStatisticsTree {
* (org.eclipse.linuxtools.tmf.core.event.ITmfEvent, org.eclipse.linuxtools.tmf.ui.viewers.statistics.ITmfExtraEventInfo, int)
*/
@Override
- public void increase(ITmfEvent event, ITmfExtraEventInfo extraInfo, int values) {
- // Do nothing
+ public void registerEvent(ITmfEvent event, ITmfExtraEventInfo extraInfo, int values) {
+ TmfFixedArray<String>[] paths = getNormalPaths(event, extraInfo);
+ for (TmfFixedArray<String> path : paths) {
+ getOrCreate(path).getValue().incrementTotal(values);
+ }
+
+ paths = getTypePaths(event, extraInfo);
+ for (TmfFixedArray<String> path : paths) {
+ getOrCreate(path).getValue().incrementTotal(values);
+ }
}
/*
@@ -186,6 +194,19 @@ public class TmfBaseStatisticsTree extends AbsTmfStatisticsTree {
}
}
+ @Override
+ public void registerEventInTimeRange(ITmfEvent event, ITmfExtraEventInfo extraInfo, int qty) {
+ TmfFixedArray<String>[] paths = getNormalPaths(event, extraInfo);
+ for (TmfFixedArray<String> path : paths) {
+ getOrCreate(path).getValue().incrementPartial(qty);
+ }
+
+ paths = getTypePaths(event, extraInfo);
+ for (TmfFixedArray<String> path : paths) {
+ getOrCreate(path).getValue().incrementPartial(qty);
+ }
+ }
+
/*
* (non-Javadoc)
*
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfStatisticsTreeNode.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfStatisticsTreeNode.java
index ca68a8c..f6a42fd 100755
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfStatisticsTreeNode.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfStatisticsTreeNode.java
@@ -158,6 +158,19 @@ public class TmfStatisticsTreeNode {
}
/**
+ * Resets the global number of events. It doesn't remove any node
+ * and doesn't modify the partial event count.
+ *
+ * Works recursively.
+ *
+ * @since 2.0
+ */
+ public void resetGlobalValue() {
+ getValue().resetTotalCount();
+ fNodes.resetGlobalValue(fPath);
+ }
+
+ /**
* Resets the number of events in the time range. It doesn't remove any node
* and doesn't modify the global event count.
*
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsView.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsView.java
index f81d785..ac2bda9 100755
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsView.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsView.java
@@ -149,7 +149,7 @@ public class TmfStatisticsView extends TmfView {
fStatsViewers.layout();
if (fRequestData) {
- TmfExperimentRangeUpdatedSignal updateSignal = new TmfExperimentRangeUpdatedSignal(null, fExperiment, fExperiment.getTimeRange());
+ TmfExperimentRangeUpdatedSignal updateSignal = new TmfExperimentRangeUpdatedSignal(this, fExperiment, fExperiment.getTimeRange());
TmfStatisticsViewer statsViewer;
// Synchronizes the request to make them coalesced
fExperiment.startSynch(new TmfStartSynchSignal(0));
@@ -228,10 +228,12 @@ public class TmfStatisticsView extends TmfView {
Composite folder = fStatsViewers.getParentFolder();
// Instantiation of the global viewer
- TmfStatisticsViewer globalViewer = new TmfStatisticsViewer();
+ TmfStatisticsViewer globalViewer = getGlobalViewer();
if (fExperiment != null) {
- // Shows the name of the experiment in the global tab
- globalViewer.init(folder, Messages.TmfStatisticsView_GlobalTabName + " - " + fExperiment.getName(), fExperiment); //$NON-NLS-1$
+ if (globalViewer != null) {
+ // Shows the name of the experiment in the global tab
+ globalViewer.init(folder, Messages.TmfStatisticsView_GlobalTabName + " - " + fExperiment.getName(), fExperiment); //$NON-NLS-1$
+ }
fStatsViewers.addTab(globalViewer, Messages.TmfStatisticsView_GlobalTabName, defaultStyle);
String traceName;
@@ -252,8 +254,10 @@ public class TmfStatisticsView extends TmfView {
}
}
} else {
- // There is no experiment selected. Shows an empty global tab
- globalViewer.init(folder, Messages.TmfStatisticsView_GlobalTabName, fExperiment);
+ if (globalViewer != null) {
+ // There is no experiment selected. Shows an empty global tab
+ globalViewer.init(folder, Messages.TmfStatisticsView_GlobalTabName, fExperiment);
+ }
fStatsViewers.addTab(globalViewer, Messages.TmfStatisticsView_GlobalTabName, defaultStyle);
}
// Makes the global viewer visible
@@ -277,4 +281,12 @@ public class TmfStatisticsView extends TmfView {
protected static TmfStatisticsViewer getStatisticsViewer(IResource resource) {
return (TmfStatisticsViewer) TmfTraceType.getTraceTypeElement(resource, TmfTraceType.STATISTICS_VIEWER_ELEM);
}
+
+ /**
+ * @return The class to use to instantiate the global statistics viewer
+ * @since 2.0
+ */
+ protected TmfStatisticsViewer getGlobalViewer() {
+ return new TmfStatisticsViewer();
+ }
}