summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorCamilo Bernal2013-04-02 15:56:05 (EDT)
committer Roland Grunberg2013-04-24 13:23:53 (EDT)
commit7307726ed6d925d63b74639d08b58cfb2c13a9f9 (patch)
treeaebe2c58487fc4eb0d12cdf2344e7b0e942df169
parentd23d194805cfac7e5220e629435824ba50a6f3f7 (diff)
downloadorg.eclipse.linuxtools-7307726ed6d925d63b74639d08b58cfb2c13a9f9.zip
org.eclipse.linuxtools-7307726ed6d925d63b74639d08b58cfb2c13a9f9.tar.gz
org.eclipse.linuxtools-7307726ed6d925d63b74639d08b58cfb2c13a9f9.tar.bz2
Add support for quick perf stat session comparison.refs/changes/16/11616/7
Add menu command to perf stat view to compare most recent stat sessions with the previous one. Change-Id: Ia29132c9f45600dd8a0ff24f1b6ee2c716c2cc97 Reviewed-on: https://git.eclipse.org/r/11616 Tested-by: Hudson CI Reviewed-by: Roland Grunberg <rgrunber@redhat.com> IP-Clean: Roland Grunberg <rgrunber@redhat.com> Tested-by: Roland Grunberg <rgrunber@redhat.com>
-rw-r--r--perf/org.eclipse.linuxtools.perf/plugin.xml11
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfPlugin.java18
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/handlers/PerfStatsComparisonHandler.java2
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/handlers/PerfStatsQuickDiffHandler.java82
4 files changed, 112 insertions, 1 deletions
diff --git a/perf/org.eclipse.linuxtools.perf/plugin.xml b/perf/org.eclipse.linuxtools.perf/plugin.xml
index 9140ee5..ec0cb4f 100644
--- a/perf/org.eclipse.linuxtools.perf/plugin.xml
+++ b/perf/org.eclipse.linuxtools.perf/plugin.xml
@@ -197,6 +197,12 @@
label="Compare Statistics"
style="push">
</command>
+ <command
+ commandId="org.eclipse.linuxtools.perf.QuickStatDiff"
+ id="org.eclipse.linuxtools.perf.QuickStatDiff"
+ label="Compare Latest"
+ style="push">
+ </command>
</menuContribution>
</extension>
<extension
@@ -216,5 +222,10 @@
id="org.eclipse.linuxtools.perf.StatDiff"
name="Compare Statistics">
</command>
+ <command
+ defaultHandler="org.eclipse.linuxtools.internal.perf.handlers.PerfStatsQuickDiffHandler"
+ id="org.eclipse.linuxtools.perf.QuickStatDiff"
+ name="Compare Latest">
+ </command>
</extension>
</plugin>
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfPlugin.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfPlugin.java
index 1645d06..0dc03a9 100644
--- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfPlugin.java
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfPlugin.java
@@ -14,6 +14,7 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.perf;
+import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.List;
@@ -102,6 +103,8 @@ public class PerfPlugin extends AbstractUIPlugin {
public static final String PERF_COMMAND = "perf";
public static final String PERF_DEFAULT_DATA = "perf.data";
+ public static final String PERF_DEFAULT_STAT= "perf.stat";
+ public static final String PERF_DEAFULT_OLD_STAT = "perf.old.stat";
public static final boolean DEBUG_ON = false; //Spew debug messages or not.
@@ -154,6 +157,21 @@ public class PerfPlugin extends AbstractUIPlugin {
}
/**
+ * Get perf file with specified name under the current profiled project.
+ *
+ * @param fileName file name.
+ * @return File corresponding to given file or null if no working directory
+ * has been set.
+ */
+ public File getPerfFile(String fileName) {
+ if (curWorkingDir != null) {
+ IPath curStatPath = curWorkingDir.append(fileName);
+ return curStatPath.toFile();
+ }
+ return null;
+ }
+
+ /**
* Return cleared model root.
* @return TreeParent cleared model root.
*/
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/handlers/PerfStatsComparisonHandler.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/handlers/PerfStatsComparisonHandler.java
index 3099763..2cd8a24 100644
--- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/handlers/PerfStatsComparisonHandler.java
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/handlers/PerfStatsComparisonHandler.java
@@ -19,7 +19,7 @@ import org.eclipse.linuxtools.internal.perf.StatComparisonData;
import org.eclipse.linuxtools.internal.perf.ui.StatComparisonView;
/**
- * Command handler for comparins perf statistics files.
+ * Command handler for comparing perf statistics files.
*/
public class PerfStatsComparisonHandler extends AbstractComparisonHandler {
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/handlers/PerfStatsQuickDiffHandler.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/handlers/PerfStatsQuickDiffHandler.java
new file mode 100644
index 0000000..b44ca55
--- /dev/null
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/handlers/PerfStatsQuickDiffHandler.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camilo Bernal <cabernal@redhat.com> - Initial Implementation.
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.perf.handlers;
+
+import java.io.File;
+import java.text.MessageFormat;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.commands.IHandlerListener;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.linuxtools.internal.perf.PerfPlugin;
+import org.eclipse.linuxtools.internal.perf.StatComparisonData;
+import org.eclipse.linuxtools.internal.perf.ui.StatComparisonView;
+
+/**
+ * Command handler for quick comparison between current and previous sessions.
+ */
+public class PerfStatsQuickDiffHandler implements IHandler {
+ @Override
+ public Object execute(ExecutionEvent event) {
+
+ // get default files
+ PerfPlugin plugin = PerfPlugin.getDefault();
+ File curStatData = plugin.getPerfFile(PerfPlugin.PERF_DEFAULT_STAT);
+ File prevStatData = plugin.getPerfFile(PerfPlugin.PERF_DEAFULT_OLD_STAT);
+
+ String title = MessageFormat.format(Messages.ContentDescription_0,
+ new Object[] { prevStatData.getName(), curStatData.getName() });
+
+ // create comparison data and run comparison
+ StatComparisonData diffData = new StatComparisonData(title,
+ prevStatData, curStatData);
+ diffData.runComparison();
+
+ // set comparison data and fill view
+ plugin.setStatDiffData(diffData);
+ StatComparisonView.refreshView();
+
+ return null;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ PerfPlugin plugin = PerfPlugin.getDefault();
+ IPath workingDir = plugin.getWorkingDir();
+ if (workingDir != null) {
+ File curStatData = plugin.getPerfFile(PerfPlugin.PERF_DEFAULT_STAT);
+ File prevStatData = plugin.getPerfFile(PerfPlugin.PERF_DEAFULT_OLD_STAT);
+ return (curStatData.exists() && prevStatData.exists());
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isHandled() {
+ return isEnabled();
+ }
+
+ @Override
+ public void addHandlerListener(IHandlerListener handlerListener) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void dispose() {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void removeHandlerListener(IHandlerListener handlerListener) {
+ // TODO Auto-generated method stub
+ }
+}