001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: * The Original Software is NetBeans. The Initial Developer of the Original
026: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
027: * Microsystems, Inc. All Rights Reserved.
028: *
029: * If you wish your version of this file to be governed by only the CDDL
030: * or only the GPL Version 2, indicate your decision by adding
031: * "[Contributor] elects to include this software in this distribution
032: * under the [CDDL or GPL Version 2] license." If you do not indicate a
033: * single choice of license, a recipient has the option to distribute
034: * your version of this file under either the CDDL, the GPL Version 2 or
035: * to extend the choice of license to its licensees as provided above.
036: * However, if you add GPL Version 2 code and therefore, elected the GPL
037: * Version 2 license, then the option applies only if the new code is
038: * made subject to such option by the copyright holder.
039: */
040:
041: package org.netbeans.lib.profiler.common;
042:
043: import org.netbeans.lib.profiler.global.CommonConstants;
044: import java.util.ResourceBundle;
045:
046: /**
047: * Factory class to create preset ProfilingSettings
048: *
049: * @author Jiri Sedlacek
050: */
051: public class ProfilingSettingsPresets {
052: //~ Inner Classes ------------------------------------------------------------------------------------------------------------
053:
054: private static final class CPUPreset extends ProfilingSettings {
055: //~ Constructors ---------------------------------------------------------------------------------------------------------
056:
057: public CPUPreset(int type) {
058: setIsPreset(true);
059: setProfilingType(type);
060: setSettingsName(CPU_PRESET_NAME);
061:
062: setCPUProfilingType(CommonConstants.CPU_INSTR_FULL);
063: setInstrumentGetterSetterMethods(false);
064: setInstrumentEmptyMethods(false);
065: setInstrumentMethodInvoke(true);
066: setExcludeWaitTime(true);
067:
068: if (type == ProfilingSettings.PROFILE_CPU_ENTIRE) {
069: setInstrScheme(CommonConstants.INSTRSCHEME_TOTAL);
070: // setInstrumentSpawnedThreads(true);
071: setInstrumentSpawnedThreads(false); // Should work better with Marker Methods
072: } else if (type == ProfilingSettings.PROFILE_CPU_PART) {
073: setInstrScheme(CommonConstants.INSTRSCHEME_LAZY);
074: setInstrumentSpawnedThreads(false);
075: }
076: }
077: }
078:
079: private static final class MemoryPreset extends ProfilingSettings {
080: //~ Constructors ---------------------------------------------------------------------------------------------------------
081:
082: public MemoryPreset(int type) {
083: setIsPreset(true);
084: setProfilingType(type);
085: setSettingsName(MEMORY_PRESET_NAME);
086: }
087: }
088:
089: private static final class MonitorPreset extends ProfilingSettings {
090: //~ Constructors ---------------------------------------------------------------------------------------------------------
091:
092: public MonitorPreset() {
093: setIsPreset(true);
094: setProfilingType(ProfilingSettings.PROFILE_MONITOR);
095: setSettingsName(MONITOR_PRESET_NAME);
096: }
097: }
098:
099: //~ Static fields/initializers -----------------------------------------------------------------------------------------------
100:
101: // -----
102: // I18N String constants
103: private static final ResourceBundle bundle = ResourceBundle
104: .getBundle("org.netbeans.lib.profiler.common.Bundle"); // NOI18N
105: private static final String MONITOR_PRESET_NAME = bundle
106: .getString("ProfilingSettingsPresets_MonitorPresetName"); // NOI18N
107: private static final String CPU_PRESET_NAME = bundle
108: .getString("ProfilingSettingsPresets_CpuPresetName"); // NOI18N
109: private static final String MEMORY_PRESET_NAME = bundle
110: .getString("ProfilingSettingsPresets_MemoryPresetName"); // NOI18N
111:
112: // -----
113:
114: //~ Methods ------------------------------------------------------------------------------------------------------------------
115:
116: public static ProfilingSettings createCPUPreset() {
117: return createCPUPreset(ProfilingSettings.PROFILE_CPU_ENTIRE);
118: }
119:
120: public static ProfilingSettings createCPUPreset(int type) {
121: return new CPUPreset(type);
122: }
123:
124: public static ProfilingSettings createMemoryPreset() {
125: return createMemoryPreset(ProfilingSettings.PROFILE_MEMORY_ALLOCATIONS);
126: }
127:
128: public static ProfilingSettings createMemoryPreset(int type) {
129: return new MemoryPreset(type);
130: }
131:
132: public static ProfilingSettings createMonitorPreset() {
133: return new MonitorPreset();
134: }
135: }
|