Source Code Cross Referenced for UIStats.java in  » IDE-Eclipse » ui-workbench » org » eclipse » ui » internal » misc » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » ui workbench » org.eclipse.ui.internal.misc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2006 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.ui.internal.misc;
011:
012:        import java.util.HashMap;
013:
014:        import org.eclipse.core.runtime.PerformanceStats;
015:        import org.eclipse.core.runtime.Platform;
016:        import org.eclipse.ui.PlatformUI;
017:
018:        /**
019:         * This class is used for monitoring performance events.  Each performance
020:         * event has an associated option in the org.eclipse.ui plugin's .options file
021:         * that specifies an maximum acceptable duration for that event.
022:         * 
023:         * @see org.eclipse.core.runtime.PerformanceStats
024:         */
025:        public class UIStats {
026:
027:            private static HashMap operations = new HashMap();
028:
029:            public static final int CREATE_PART = 0;
030:
031:            public static final int CREATE_PART_CONTROL = 1;
032:
033:            public static final int INIT_PART = 2;
034:
035:            public static final int CREATE_PERSPECTIVE = 3;
036:
037:            public static final int RESTORE_WORKBENCH = 4;
038:
039:            public static final int START_WORKBENCH = 5;
040:
041:            public static final int CREATE_PART_INPUT = 6;
042:
043:            public static final int ACTIVATE_PART = 7;
044:
045:            public static final int BRING_PART_TO_TOP = 8;
046:
047:            public static final int NOTIFY_PART_LISTENERS = 9;
048:
049:            public static final int SWITCH_PERSPECTIVE = 10;
050:
051:            public static final int NOTIFY_PAGE_LISTENERS = 11;
052:
053:            public static final int NOTIFY_PERSPECTIVE_LISTENERS = 12;
054:
055:            public static final int UI_JOB = 13;
056:
057:            public static final int CONTENT_TYPE_LOOKUP = 14;
058:
059:            /**
060:             * Change this value when you add a new event constant.
061:             */
062:            public static final int LAST_VALUE = CONTENT_TYPE_LOOKUP;
063:
064:            private static boolean debug[] = new boolean[LAST_VALUE + 1];
065:
066:            private static String[] events = new String[LAST_VALUE + 1];
067:
068:            static {
069:                events[CREATE_PART] = PlatformUI.PLUGIN_ID
070:                        + "/perf/part.create"; //$NON-NLS-1$
071:                events[CREATE_PART_INPUT] = PlatformUI.PLUGIN_ID
072:                        + "/perf/part.input"; //$NON-NLS-1$
073:                events[CREATE_PART_CONTROL] = PlatformUI.PLUGIN_ID
074:                        + "/perf/part.control"; //$NON-NLS-1$
075:                events[INIT_PART] = PlatformUI.PLUGIN_ID + "/perf/part.init"; //$NON-NLS-1$
076:                events[CREATE_PERSPECTIVE] = PlatformUI.PLUGIN_ID
077:                        + "/perf/perspective.create"; //$NON-NLS-1$
078:                events[SWITCH_PERSPECTIVE] = PlatformUI.PLUGIN_ID
079:                        + "/perf/perspective.switch"; //$NON-NLS-1$
080:                events[RESTORE_WORKBENCH] = PlatformUI.PLUGIN_ID
081:                        + "/perf/workbench.restore"; //$NON-NLS-1$
082:                events[START_WORKBENCH] = PlatformUI.PLUGIN_ID
083:                        + "/perf/workbench.start"; //$NON-NLS-1$
084:                events[ACTIVATE_PART] = PlatformUI.PLUGIN_ID
085:                        + "/perf/part.activate"; //$NON-NLS-1$
086:                events[BRING_PART_TO_TOP] = PlatformUI.PLUGIN_ID
087:                        + "/perf/part.activate"; //$NON-NLS-1$
088:                events[NOTIFY_PART_LISTENERS] = PlatformUI.PLUGIN_ID
089:                        + "/perf/part.listeners"; //$NON-NLS-1$
090:                events[NOTIFY_PAGE_LISTENERS] = PlatformUI.PLUGIN_ID
091:                        + "/perf/page.listeners"; //$NON-NLS-1$
092:                events[NOTIFY_PERSPECTIVE_LISTENERS] = PlatformUI.PLUGIN_ID
093:                        + "/perf/perspective.listeners"; //$NON-NLS-1$
094:                events[UI_JOB] = PlatformUI.PLUGIN_ID + "/perf/uijob"; //$NON-NLS-1$
095:                events[CONTENT_TYPE_LOOKUP] = PlatformUI.PLUGIN_ID
096:                        + "/perf/contentTypes"; //$NON-NLS-1$
097:
098:                for (int i = 0; i <= LAST_VALUE; i++) {
099:                    //don't log any performance events if the general performance stats is disabled
100:                    if (events[i] != null && PerformanceStats.ENABLED) {
101:                        debug[i] = PerformanceStats.isEnabled(events[i]);
102:                    }
103:                }
104:            }
105:
106:            /**
107:             * Returns whether tracing of the given debug event is turned on.
108:             * 
109:             * @param event The event id
110:             * @return <code>true</code> if tracing of this event is turned on,
111:             * and <code>false</code> otherwise.
112:             */
113:            public static boolean isDebugging(int event) {
114:                return debug[event];
115:            }
116:
117:            /**
118:             * Indicates the start of a performance event
119:             * 
120:             * @param event The event id
121:             * @param label The event label
122:             */
123:            public static void start(int event, String label) {
124:                if (debug[event]) {
125:                    operations.put(event + label, new Long(System
126:                            .currentTimeMillis()));
127:                }
128:            }
129:
130:            /**
131:             * Indicates the end of a performance operation
132:             * 
133:             * @param event The event id
134:             * @param blame An object that is responsible for the event that occurred,
135:             * or that uniquely describes the event that occurred
136:             * @param label The event label
137:             */
138:            public static void end(int event, Object blame, String label) {
139:                if (debug[event]) {
140:                    Long startTime = (Long) operations.remove(event + label);
141:                    if (startTime == null) {
142:                        return;
143:                    }
144:                    final long elapsed = System.currentTimeMillis()
145:                            - startTime.longValue();
146:                    //			System.out.println("Time - " + //$NON-NLS-1$
147:                    //                    elapsed + events[event] + label);
148:                    PerformanceStats.getStats(events[event], blame).addRun(
149:                            elapsed, label);
150:                }
151:            }
152:
153:            /**
154:             * Special hook to signal that application startup is complete and the event
155:             * loop has started running.
156:             */
157:            public static void startupComplete() {
158:                // We use a runtime debug option here for backwards compatibility (bug 96672)
159:                // Note that this value is only relevant if the workspace chooser is not used.
160:                String option = Platform.getDebugOption(Platform.PI_RUNTIME
161:                        + "/debug"); //$NON-NLS-1$
162:                if (option == null || !"true".equalsIgnoreCase(option)) { //$NON-NLS-1$
163:                    return;
164:                }
165:                String startString = System.getProperty("eclipse.startTime"); //$NON-NLS-1$
166:                if (startString == null) {
167:                    return;
168:                }
169:                try {
170:                    long start = Long.parseLong(startString);
171:                    long end = System.currentTimeMillis();
172:                    System.out
173:                            .println("Startup complete: " + (end - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
174:                } catch (NumberFormatException e) {
175:                    //this is just debugging code -- ok to swallow exception
176:                }
177:            }
178:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.