1 11 package org.eclipse.core.internal.events; 12 13 import org.eclipse.core.resources.*; 14 import org.eclipse.core.runtime.PerformanceStats; 15 16 20 public class ResourceStats { 21 24 private static PerformanceStats currentStats; 25 public static final String EVENT_BUILDERS = ResourcesPlugin.PI_RESOURCES + "/perf/builders"; public static final String EVENT_LISTENERS = ResourcesPlugin.PI_RESOURCES + "/perf/listeners"; public static final String EVENT_SAVE_PARTICIPANTS = ResourcesPlugin.PI_RESOURCES + "/perf/save.participants"; public static final String EVENT_SNAPSHOT = ResourcesPlugin.PI_RESOURCES + "/perf/snapshot"; 31 public static boolean TRACE_BUILDERS = PerformanceStats.isEnabled(ResourceStats.EVENT_BUILDERS); 33 public static boolean TRACE_LISTENERS = PerformanceStats.isEnabled(ResourceStats.EVENT_LISTENERS); 34 public static boolean TRACE_SAVE_PARTICIPANTS = PerformanceStats.isEnabled(ResourceStats.EVENT_SAVE_PARTICIPANTS); 35 public static boolean TRACE_SNAPSHOT = PerformanceStats.isEnabled(ResourceStats.EVENT_SNAPSHOT); 36 37 public static void endBuild() { 38 if (currentStats != null) 39 currentStats.endRun(); 40 currentStats = null; 41 } 42 43 public static void endNotify() { 44 if (currentStats != null) 45 currentStats.endRun(); 46 currentStats = null; 47 } 48 49 public static void endSave() { 50 if (currentStats != null) 51 currentStats.endRun(); 52 currentStats = null; 53 } 54 55 public static void endSnapshot() { 56 if (currentStats != null) 57 currentStats.endRun(); 58 currentStats = null; 59 } 60 61 64 public static void listenerAdded(IResourceChangeListener listener) { 65 if (listener != null) 66 PerformanceStats.getStats(EVENT_LISTENERS, listener.getClass().getName()); 67 } 68 69 72 public static void listenerRemoved(IResourceChangeListener listener) { 73 if (listener != null) 74 PerformanceStats.removeStats(EVENT_LISTENERS, listener.getClass().getName()); 75 } 76 77 public static void startBuild(IncrementalProjectBuilder builder) { 78 currentStats = PerformanceStats.getStats(EVENT_BUILDERS, builder); 79 currentStats.startRun(builder.getProject().getName()); 80 } 81 82 public static void startNotify(IResourceChangeListener listener) { 83 currentStats = PerformanceStats.getStats(EVENT_LISTENERS, listener); 84 currentStats.startRun(); 85 } 86 87 public static void startSnapshot() { 88 currentStats = PerformanceStats.getStats(EVENT_SNAPSHOT, ResourcesPlugin.getWorkspace()); 89 currentStats.startRun(); 90 } 91 92 public static void startSave(ISaveParticipant participant) { 93 currentStats = PerformanceStats.getStats(EVENT_SAVE_PARTICIPANTS, participant); 94 currentStats.startRun(); 95 } 96 } | Popular Tags |