RuntimePerformanceMonitor disabled by default, bug 417668
diff --git a/core/plugins/org.eclipse.dltk.core.tools.ui/src/org/eclipse/dltk/core/tools/internal/ui/DLTKPerformanceViewPart.java b/core/plugins/org.eclipse.dltk.core.tools.ui/src/org/eclipse/dltk/core/tools/internal/ui/DLTKPerformanceViewPart.java
index f8def7d..6c9b02d 100644
--- a/core/plugins/org.eclipse.dltk.core.tools.ui/src/org/eclipse/dltk/core/tools/internal/ui/DLTKPerformanceViewPart.java
+++ b/core/plugins/org.eclipse.dltk.core.tools.ui/src/org/eclipse/dltk/core/tools/internal/ui/DLTKPerformanceViewPart.java
@@ -20,6 +20,8 @@
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.PartInitException;
import org.eclipse.ui.contexts.IContextActivation;
import org.eclipse.ui.contexts.IContextService;
import org.eclipse.ui.part.ViewPart;
@@ -160,6 +162,11 @@
public DLTKPerformanceViewPart() {
}
+ public void init(IViewSite site) throws PartInitException {
+ super.init(site);
+ RuntimePerformanceMonitor.setActive(true);
+ }
+
Runnable update = new Runnable() {
public void run() {
if (!viewer.getTree().isDisposed()) {
diff --git a/core/plugins/org.eclipse.dltk.core/.options b/core/plugins/org.eclipse.dltk.core/.options
index e9a15a9..7e87d5b 100644
--- a/core/plugins/org.eclipse.dltk.core/.options
+++ b/core/plugins/org.eclipse.dltk.core/.options
@@ -13,4 +13,5 @@
org.eclipse.dltk.core/debugPrintModel = false
org.eclipse.dltk.core/traceAST/dltk = false
org.eclipse.dltk.core/show_reindex = false
+org.eclipse.dltk.core/performanceMonitor = false
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/RuntimePerformanceMonitor.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/RuntimePerformanceMonitor.java
index 1c18c37..0a55bf3 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/RuntimePerformanceMonitor.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/RuntimePerformanceMonitor.java
@@ -1,5 +1,7 @@
package org.eclipse.dltk.core;
+import static org.eclipse.core.runtime.Platform.getDebugOption;
+
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -11,8 +13,30 @@
public static final String IOREAD = "IO Read";
public static final String IOWRITE = "IO Write";
+ /**
+ * TODO (alex) This field was never used, remove in 6.0
+ */
+ @Deprecated
public static boolean RUNTIME_PERFORMANCE = true;
+ private static volatile boolean active = Boolean.valueOf(
+ getDebugOption("org.eclipse.dltk.core/performanceMonitor")) //$NON-NLS-1$
+ .booleanValue();
+
+ /**
+ * @since 5.1
+ */
+ public static boolean isActive() {
+ return active;
+ }
+
+ /**
+ * @since 5.1
+ */
+ public static void setActive(boolean value) {
+ active = value;
+ }
+
public static class DataEntry {
long count = 0;
long total = 0;
@@ -31,8 +55,11 @@
}
}
- private static Map<String, Map<String, DataEntry>> entries = new HashMap<String, Map<String, DataEntry>>();
+ private static final Map<String, Map<String, DataEntry>> entries = new HashMap<String, Map<String, DataEntry>>();
+ /**
+ * @noreference This method is not intended to be referenced by clients.
+ */
public static synchronized void updateData(String language, String kind,
long time, long value) {
Map<String, DataEntry> attrs = internalGetEntries(language);
@@ -46,6 +73,9 @@
entry.time += time;
}
+ /**
+ * @noreference This method is not intended to be referenced by clients.
+ */
public static synchronized void updateData(String language, String kind,
long time, long value, IEnvironment env) {
if (env != null) {
@@ -79,7 +109,7 @@
}
public static Map<String, Map<String, DataEntry>> getAllEntries() {
- Set<String> keySet = null;
+ final Set<String> keySet;
synchronized (RuntimePerformanceMonitor.class) {
keySet = new HashSet<String>(entries.keySet());
}
@@ -119,7 +149,36 @@
}
}
+ private static final class DummyPerformanceNode extends PerformanceNode {
+ @Override
+ public long done() {
+ // empty
+ return 0;
+ }
+
+ @Override
+ public void renew() {
+ // empty
+ }
+
+ @Override
+ public void done(String natureId, String kind, long value,
+ IEnvironment environment) {
+ // empty
+ }
+
+ @Override
+ public void done(String natureId, String string, long value) {
+ // empty
+ }
+ }
+
+ private static final DummyPerformanceNode dummyNode = new DummyPerformanceNode();
+
public static PerformanceNode begin() {
+ if (!active) {
+ return dummyNode;
+ }
PerformanceNode node = new PerformanceNode();
node.renew();
return node;