0001: /*
0002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0003: *
0004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
0005: *
0006: * The contents of this file are subject to the terms of either the GNU
0007: * General Public License Version 2 only ("GPL") or the Common
0008: * Development and Distribution License("CDDL") (collectively, the
0009: * "License"). You may not use this file except in compliance with the
0010: * License. You can obtain a copy of the License at
0011: * http://www.netbeans.org/cddl-gplv2.html
0012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
0013: * specific language governing permissions and limitations under the
0014: * License. When distributing the software, include this License Header
0015: * Notice in each file and include the License file at
0016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
0017: * particular file as subject to the "Classpath" exception as provided
0018: * by Sun in the GPL Version 2 section of the License file that
0019: * accompanied this code. If applicable, add the following below the
0020: * License Header, with the fields enclosed by brackets [] replaced by
0021: * your own identifying information:
0022: * "Portions Copyrighted [year] [name of copyright owner]"
0023: *
0024: * Contributor(s):
0025: * The Original Software is NetBeans. The Initial Developer of the Original
0026: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
0027: * Microsystems, Inc. All Rights Reserved.
0028: *
0029: * If you wish your version of this file to be governed by only the CDDL
0030: * or only the GPL Version 2, indicate your decision by adding
0031: * "[Contributor] elects to include this software in this distribution
0032: * under the [CDDL or GPL Version 2] license." If you do not indicate a
0033: * single choice of license, a recipient has the option to distribute
0034: * your version of this file under either the CDDL, the GPL Version 2 or
0035: * to extend the choice of license to its licensees as provided above.
0036: * However, if you add GPL Version 2 code and therefore, elected the GPL
0037: * Version 2 license, then the option applies only if the new code is
0038: * made subject to such option by the copyright holder.
0039: */
0040:
0041: package org.netbeans.lib.profiler.common;
0042:
0043: import org.netbeans.lib.profiler.ProfilerEngineSettings;
0044: import org.netbeans.lib.profiler.client.ClientUtils;
0045: import org.netbeans.lib.profiler.common.filters.FilterSet;
0046: import org.netbeans.lib.profiler.common.filters.FilterUtils;
0047: import org.netbeans.lib.profiler.common.filters.GlobalFilters;
0048: import org.netbeans.lib.profiler.common.filters.SimpleFilter;
0049: import org.netbeans.lib.profiler.global.CommonConstants;
0050: import org.netbeans.lib.profiler.global.InstrumentationFilter;
0051: import java.util.ArrayList;
0052: import java.util.Arrays;
0053: import java.util.HashSet;
0054: import java.util.Iterator;
0055: import java.util.List;
0056: import java.util.Map;
0057: import java.util.ResourceBundle;
0058: import java.util.Set;
0059:
0060: /**
0061: * A Class holding a single named profiling configuration settings within the IDE.
0062: *
0063: * @author Tomas Hurka
0064: * @author Ian Formanek
0065: * @author Jiri Sedlacek
0066: */
0067: public class ProfilingSettings {
0068: //~ Static fields/initializers -----------------------------------------------------------------------------------------------
0069:
0070: // -----
0071: // I18N String constants
0072: private static final ResourceBundle bundle = ResourceBundle
0073: .getBundle("org.netbeans.lib.profiler.common.Bundle"); // NOI18N
0074: static final String DEFAULT_PROFILING_SETTINGS_NAME = bundle
0075: .getString("ProfilingSettings_DefaultProfilingSettingsName"); // NOI18N
0076: private static final String UNKNOWN_PROFILING_SETTINGS_NAME = bundle
0077: .getString("ProfilingSettings_UnknownProfilingSettingsName"); // NOI18N
0078: // -----
0079:
0080: // Profiling modes
0081: public static final int PROFILE_MONITOR = 1; // just monitoring
0082: public static final int PROFILE_MEMORY_ALLOCATIONS = 2; // memory: allocations
0083: public static final int PROFILE_MEMORY_LIVENESS = 4; // memory: liveness
0084: public static final int PROFILE_CPU_ENTIRE = 8; // cpu: entire app (root = main)
0085: public static final int PROFILE_CPU_PART = 16; // cpu: root methods
0086: public static final int PROFILE_CPU_STOPWATCH = 32; // cpu: code fragment
0087: public static final boolean QUICK_FILTER_INCLUSIVE = true;
0088: public static final boolean QUICK_FILTER_EXCLUSIVE = false;
0089: public static final String LINES_PREFIX = "[lines]"; //NOI18N
0090: public static final String PROP_OVERRIDE_GLOBAL_SETTINGS = "profiler.settings.override"; //NOI18N
0091: public static final String PROP_WORKING_DIR = "profiler.settings.override.working.dir"; //NOI18N
0092: public static final String PROP_JVM_ARGS = "profiler.settings.override.jvm.args"; //NOI18N
0093: public static final String PROP_JAVA_PLATFORM = "profiler.settings.override.java.platform"; //NOI18N
0094: public static final String PROP_IS_PRESET = "profiler.settigns.ispreset"; // NOI18N
0095: public static final String PROP_SETTINGS_NAME = "profiler.settings.settings.name"; //NOI18N
0096: public static final String PROP_PROFILING_TYPE = "profiler.settings.profiling.type"; //NOI18N
0097: public static final String PROP_THREADS_MONITORING_ENABLED = "profiler.settings.threads.monitoring.enabled"; //NOI18N
0098: public static final String PROP_CPU_PROFILING_TYPE = "profiler.settings.cpu.profiling.type"; //NOI18N
0099: public static final String PROP_EXCLUDE_WAIT_TIME = "profiler.settings.cpu.exclude.wait.time"; // NOI18N
0100: public static final String PROP_INSTR_SCHEME = "profiler.settings.instr.scheme"; //NOI18N
0101: public static final String PROP_THREAD_CPU_TIMER_ON = "profiler.settings.thread.cpu.timer.on"; //NOI18N
0102: public static final String PROP_INSTRUMENT_GETTER_SETTER_METHODS = "profiler.settings.istrument.getter.setter.methods"; //NOI18N
0103: public static final String PROP_INSTRUMENT_EMPTY_METHODS = "profiler.settings.instrument.empty.methods"; //NOI18N
0104: public static final String PROP_INSTRUMENT_METHOD_INVOKE = "profiler.settings.instrument.method.invoke"; //NOI18N
0105: public static final String PROP_INSTRUMENT_SPAWNED_THREADS = "profiler.settings.instrument.spawned.threads"; //NOI18N
0106: public static final String PROP_N_PROFILED_THREADS_LIMIT = "profiler.settings.n.profiled.threads.limit"; //NOI18N
0107: public static final String PROP_SORT_RESULTS_BY_THREAD_CPU_TIME = "profiler.settings.sort.results.by.thread.cpu.time"; //NOI18N
0108: public static final String PROP_SAMPLING_INTERVAL = "profiler.settings.sampling.interval"; //NOI18N
0109: public static final String PROP_INSTRUMENTATION_ROOT_METHODS_SIZE = "profiler.settings.instrumentation.root.methods.size"; //NOI18N
0110: public static final String PROP_INSTRUMENTATION_ROOT_METHODS_PREFIX = "profiler.settings.istrumentation.root.methods-"; //NOI18N
0111: public static final String PROP_INSTRUMENTATION_MARKER_METHODS_SIZE = "profiler.settings.instrumentation.marker.methods.size"; //NOI18N
0112: public static final String PROP_INSTRUMENTATION_MARKER_METHODS_PREFIX = "profiler.settings.istrumentation.marker.methods-"; //NOI18N
0113: public static final String PROP_FRAGMENT_SELECTION = "profiler.settings.fragment.selection"; //NOI18N
0114: public static final String PROP_CODE_REGION_CPU_RES_BUF_SIZE = "profiler.settings.code.region.cpu.res.buf.size"; //NOI18N
0115: public static final String PROP_RUN_GC_ON_GET_RESULTS_IN_MEMORY_PROFILING = "profiler.settings.run.gc.on.get.results.in.memory.profiling"; //NOI18N
0116: public static final String PROP_OBJ_ALLOC_STACK_SAMPLING_INTERVAL = "profiler.settings.obj.alloc.stack.sampling.interval"; //NOI18N
0117: public static final String PROP_OBJ_ALLOC_STACK_SAMPLING_DEPTH = "profiler.settings.obj.alloc.stack.sampling.depth"; //NOI18N
0118: public static final String PROP_SELECTED_INSTR_FILTER = "profiler.settings.instrumentation.filter.selected"; //NOI18N
0119: public static final String PROP_PROFILE_UNDERLYING_FRAMEWORK = "profiler.settings.profile.underlying.framework"; // NOI18N
0120: public static final String PROP_PROFILING_POINTS_ENABLED = "profiler.settings.profilingpoints.enabled"; //NOI18N
0121: public static final String PROP_QUICK_FILTER = "profiler.settings.cpu.quick.filter"; //NOI18N
0122:
0123: //~ Instance fields ----------------------------------------------------------------------------------------------------------
0124:
0125: // flag for Entire application profiling, instrumentationRootMethods will be computed lazily
0126: public transient boolean instrRootMethodsPending = false;
0127:
0128: // CPU Profiling: Code Fragment
0129: private ClientUtils.SourceCodeSelection fragmentSelection = null;
0130: private List instrumentationMarkerMethods = new ArrayList();
0131:
0132: // CPU Profiling: Part of Application
0133: private List instrumentationRootMethods = new ArrayList();
0134:
0135: // CPU instrumentation filter related settings
0136: private Object selectedInstrumentationFilter = SimpleFilter.NO_FILTER; //NOI18N
0137: // QuickFilter: just for persistence
0138: private SimpleFilter quickFilter = FilterUtils.QUICK_FILTER;
0139: private String jvmArgs = ""; //NOI18N
0140: private String platformName = null; // from project
0141: private String settingsName = DEFAULT_PROFILING_SETTINGS_NAME;
0142: private String workingDir = ""; //NOI18N
0143:
0144: // CPU and Code Fragment common
0145: private boolean excludeWaitTime = true;
0146: private boolean instrumentEmptyMethods = false;
0147: private boolean instrumentGetterSetterMethods = false;
0148: private boolean instrumentMethodInvoke = true;
0149: private boolean instrumentSpawnedThreads = false;
0150:
0151: // General (global) settings
0152: private boolean isPreset = false;
0153: private boolean overrideGlobalSettings = false;
0154: private boolean profileUnderlyingFramework = false;
0155:
0156: // -- Memory profiling settings
0157: private boolean runGCOnGetResultsInMemoryProfiling = true;
0158: private boolean sortResultsByThreadCPUTime = false;
0159: private boolean threadCPUTimerOn = false;
0160: private boolean threadsMonitoringEnabled = false;
0161:
0162: // General CPU Profiling settings
0163: private boolean useProfilingPoints = true;
0164: private int allocStackTraceLimit = 0; // 0 means no stack sampling performed
0165: private int allocTrackEvery = 10; // limits the number of allocations tracked to each n-th
0166: private int codeRegionCPUResBufSize = 1000;
0167: private int cpuProfilingType = CommonConstants.CPU_INSTR_FULL;
0168: private int instrScheme = CommonConstants.INSTRSCHEME_LAZY;
0169: private int nProfiledThreadsLimit = 32;
0170: private int profilingType = PROFILE_CPU_ENTIRE;
0171:
0172: // CPU Profiling: Sampled
0173: private int samplingInterval = 10;
0174:
0175: //~ Constructors -------------------------------------------------------------------------------------------------------------
0176:
0177: // -- Constructors ---------------------------------------------------------------------------------------------------
0178: public ProfilingSettings() {
0179: }
0180:
0181: public ProfilingSettings(final String name) {
0182: this .settingsName = name;
0183: }
0184:
0185: //~ Methods ------------------------------------------------------------------------------------------------------------------
0186:
0187: public void setAllocStackTraceLimit(final int allocStackTraceLimit) {
0188: this .allocStackTraceLimit = allocStackTraceLimit;
0189: }
0190:
0191: public int getAllocStackTraceLimit() {
0192: return allocStackTraceLimit;
0193: }
0194:
0195: public void setAllocTrackEvery(final int value) {
0196: this .allocTrackEvery = value;
0197: }
0198:
0199: public int getAllocTrackEvery() {
0200: return allocTrackEvery;
0201: }
0202:
0203: /** @param cpuProfilingType Type of CPU instrumentation.
0204: * @see CommonConstants.CPU_INSTR_FULL
0205: * @see CommonConstants.CPU_INSTR_SAMPLED
0206: */
0207: public void setCPUProfilingType(final int cpuProfilingType) {
0208: this .cpuProfilingType = cpuProfilingType;
0209: }
0210:
0211: // -- General CPU Profiling settings ---------------------------------------------------------------------------------
0212:
0213: /** @return Type of CPU instrumentation
0214: * @see CommonConstants.CPU_INSTR_FULL
0215: * @see CommonConstants.CPU_INSTR_SAMPLED
0216: */
0217: public int getCPUProfilingType() {
0218: return cpuProfilingType;
0219: }
0220:
0221: /** @param fragmentSel code fragment to profile, can be null which indicates no code fragment selected */
0222: public void setCodeFragmentSelection(
0223: final ClientUtils.SourceCodeSelection fragmentSel) {
0224: this .fragmentSelection = fragmentSel;
0225: }
0226:
0227: /** @return code fragment to profile, can be null which indicates no code fragment selected */
0228: public ClientUtils.SourceCodeSelection getCodeFragmentSelection() {
0229: return fragmentSelection;
0230: }
0231:
0232: /** @param codeRegionCPUResBufSize Buffer size for code region results */
0233: public void setCodeRegionCPUResBufSize(
0234: final int codeRegionCPUResBufSize) {
0235: this .codeRegionCPUResBufSize = codeRegionCPUResBufSize;
0236: }
0237:
0238: /** @return Buffer size for code region results */
0239: public int getCodeRegionCPUResBufSize() {
0240: return codeRegionCPUResBufSize;
0241: }
0242:
0243: public void setExcludeWaitTime(boolean value) {
0244: excludeWaitTime = value;
0245: }
0246:
0247: // -- CPU and Code Fragment Profiling settings -----------------------------------------------------------------------
0248: public boolean getExcludeWaitTime() {
0249: return excludeWaitTime;
0250: }
0251:
0252: public void setInstrScheme(final int instrScheme) {
0253: this .instrScheme = instrScheme;
0254: }
0255:
0256: public int getInstrScheme() {
0257: return instrScheme;
0258: }
0259:
0260: public void setInstrumentEmptyMethods(
0261: final boolean instrumentEmptyMethods) {
0262: this .instrumentEmptyMethods = instrumentEmptyMethods;
0263: }
0264:
0265: public boolean getInstrumentEmptyMethods() {
0266: return instrumentEmptyMethods;
0267: }
0268:
0269: public void setInstrumentGetterSetterMethods(
0270: final boolean instrumentGetterSetterMethods) {
0271: this .instrumentGetterSetterMethods = instrumentGetterSetterMethods;
0272: }
0273:
0274: public boolean getInstrumentGetterSetterMethods() {
0275: return instrumentGetterSetterMethods;
0276: }
0277:
0278: public void setInstrumentMethodInvoke(
0279: final boolean instrumentMethodInvoke) {
0280: this .instrumentMethodInvoke = instrumentMethodInvoke;
0281: }
0282:
0283: public boolean getInstrumentMethodInvoke() {
0284: return instrumentMethodInvoke;
0285: }
0286:
0287: public void setInstrumentSpawnedThreads(
0288: final boolean instrumentSpawnedThreads) {
0289: this .instrumentSpawnedThreads = instrumentSpawnedThreads;
0290: }
0291:
0292: public boolean getInstrumentSpawnedThreads() {
0293: return instrumentSpawnedThreads;
0294: }
0295:
0296: public void setInstrumentationMarkerMethods(
0297: final ClientUtils.SourceCodeSelection[] markers) {
0298: instrumentationMarkerMethods.clear();
0299:
0300: for (int i = 0; i < markers.length; i++) {
0301: ClientUtils.SourceCodeSelection marker = markers[i];
0302:
0303: if (marker.isMarkerMethod()) {
0304: instrumentationMarkerMethods.add(marker);
0305: }
0306: }
0307: }
0308:
0309: public ClientUtils.SourceCodeSelection[] getInstrumentationMarkerMethods() {
0310: return (ClientUtils.SourceCodeSelection[]) instrumentationMarkerMethods
0311: .toArray(new ClientUtils.SourceCodeSelection[instrumentationMarkerMethods
0312: .size()]);
0313: }
0314:
0315: public ClientUtils.SourceCodeSelection[] getInstrumentationMethods() {
0316: Set methods = new HashSet();
0317: // Keep the order:
0318: // 1. Root methods; 2. Marker methods
0319: methods.addAll(instrumentationRootMethods);
0320: methods.addAll(instrumentationMarkerMethods);
0321:
0322: return (ClientUtils.SourceCodeSelection[]) methods
0323: .toArray(new ClientUtils.SourceCodeSelection[methods
0324: .size()]);
0325: }
0326:
0327: public void setInstrumentationRootMethods(
0328: final ClientUtils.SourceCodeSelection[] roots) {
0329: instrRootMethodsPending = false;
0330: instrumentationRootMethods.clear();
0331:
0332: for (int i = 0; i < roots.length; i++) {
0333: ClientUtils.SourceCodeSelection root = roots[i];
0334:
0335: if (!root.isMarkerMethod()) {
0336: instrumentationRootMethods.add(root);
0337: }
0338: }
0339: }
0340:
0341: public ClientUtils.SourceCodeSelection[] getInstrumentationRootMethods() {
0342: return (ClientUtils.SourceCodeSelection[]) instrumentationRootMethods
0343: .toArray(new ClientUtils.SourceCodeSelection[instrumentationRootMethods
0344: .size()]);
0345: }
0346:
0347: public void setIsPreset(boolean isPreset) {
0348: this .isPreset = isPreset;
0349: }
0350:
0351: public void setJVMArgs(final String args) {
0352: this .jvmArgs = args;
0353: }
0354:
0355: public String getJVMArgs() {
0356: return jvmArgs;
0357: }
0358:
0359: public void setJavaPlatformName(String value) {
0360: platformName = value;
0361: }
0362:
0363: public String getJavaPlatformName() {
0364: return platformName;
0365: }
0366:
0367: public void setNProfiledThreadsLimit(final int nProfiledThreadsLimit) {
0368: this .nProfiledThreadsLimit = nProfiledThreadsLimit;
0369: }
0370:
0371: public int getNProfiledThreadsLimit() {
0372: return nProfiledThreadsLimit;
0373: }
0374:
0375: public void setOverrideGlobalSettings(final boolean override) {
0376: overrideGlobalSettings = override;
0377: }
0378:
0379: public boolean getOverrideGlobalSettings() {
0380: return overrideGlobalSettings;
0381: }
0382:
0383: // -- General (global) settings --------------------------------------------------------------------------------------
0384: public boolean isPreset() {
0385: return isPreset;
0386: }
0387:
0388: public void setProfileUnderlyingFramework(final boolean profileUF) {
0389: profileUnderlyingFramework = profileUF;
0390: }
0391:
0392: public boolean getProfileUnderlyingFramework() {
0393: return profileUnderlyingFramework;
0394: }
0395:
0396: public void setProfilingType(final int profilingType) {
0397: this .profilingType = profilingType;
0398: }
0399:
0400: public int getProfilingType() {
0401: return profilingType;
0402: }
0403:
0404: public void setQuickFilter(SimpleFilter quickFilter) {
0405: this .quickFilter = quickFilter;
0406: }
0407:
0408: public SimpleFilter getQuickFilter() {
0409: return quickFilter;
0410: }
0411:
0412: public void setRunGCOnGetResultsInMemoryProfiling(
0413: final boolean runGCOnGetResultsInMemoryProfiling) {
0414: this .runGCOnGetResultsInMemoryProfiling = runGCOnGetResultsInMemoryProfiling;
0415: }
0416:
0417: // -- Memory profiling settings --------------------------------------------------------------------------------------
0418: public boolean getRunGCOnGetResultsInMemoryProfiling() {
0419: return runGCOnGetResultsInMemoryProfiling;
0420: }
0421:
0422: public void setSamplingInterval(final int samplingInterval) {
0423: this .samplingInterval = samplingInterval;
0424: }
0425:
0426: public int getSamplingInterval() {
0427: return samplingInterval;
0428: }
0429:
0430: public void setSelectedInstrumentationFilter(final Object sif) {
0431: selectedInstrumentationFilter = sif;
0432: }
0433:
0434: public Object getSelectedInstrumentationFilter() {
0435: return selectedInstrumentationFilter;
0436: }
0437:
0438: public void setSettingsName(final String name) {
0439: this .settingsName = name;
0440: }
0441:
0442: // -- Constructors ---------------------------------------------------------------------------------------------------
0443: public String getSettingsName() {
0444: return settingsName;
0445: }
0446:
0447: public void setSortResultsByThreadCPUTime(
0448: final boolean sortResultsByThreadCPUTime) {
0449: this .sortResultsByThreadCPUTime = sortResultsByThreadCPUTime;
0450: }
0451:
0452: public boolean getSortResultsByThreadCPUTime() {
0453: return sortResultsByThreadCPUTime;
0454: }
0455:
0456: public void setThreadCPUTimerOn(final boolean threadCPUTimerOn) {
0457: this .threadCPUTimerOn = threadCPUTimerOn;
0458: }
0459:
0460: public boolean getThreadCPUTimerOn() {
0461: return threadCPUTimerOn;
0462: }
0463:
0464: public void setThreadsMonitoringEnabled(final boolean enabled) {
0465: threadsMonitoringEnabled = enabled;
0466: }
0467:
0468: public boolean getThreadsMonitoringEnabled() {
0469: return threadsMonitoringEnabled;
0470: }
0471:
0472: public void setUseProfilingPoints(boolean enabled) {
0473: useProfilingPoints = enabled;
0474: }
0475:
0476: public void setWorkingDir(final String workingDir) {
0477: this .workingDir = workingDir;
0478: }
0479:
0480: public String getWorkingDir() {
0481: return workingDir;
0482: }
0483:
0484: public void addRootMethod(final String className,
0485: final String methodName, final String signature) {
0486: ClientUtils.SourceCodeSelection scs = new ClientUtils.SourceCodeSelection(
0487: className, methodName, signature);
0488:
0489: if (!instrumentationRootMethods.contains(scs)) {
0490: instrumentationRootMethods.add(scs);
0491: }
0492: }
0493:
0494: public void addRootMethods(
0495: final ClientUtils.SourceCodeSelection[] selections) {
0496: for (int i = 0; i < selections.length; i++) {
0497: if (!instrumentationRootMethods.contains(selections[i])) {
0498: instrumentationRootMethods.add(selections[i]);
0499: }
0500: }
0501: }
0502:
0503: public void applySettings(final ProfilerEngineSettings settings) {
0504: if (getOverrideGlobalSettings()) {
0505: settings.setWorkingDir(getWorkingDir());
0506: settings.setJVMArgs(getJVMArgs());
0507:
0508: if (getJavaPlatformName() != null) {
0509: settings.setTargetJVMExeFile(Profiler.getDefault()
0510: .getPlatformJavaFile(getJavaPlatformName()));
0511: settings.setTargetJDKVersionString(Profiler
0512: .getDefault().getPlatformJDKVersion(
0513: getJavaPlatformName()));
0514: settings
0515: .setSystemArchitecture(Profiler.getDefault()
0516: .getPlatformArchitecture(
0517: getJavaPlatformName()));
0518: }
0519: }
0520:
0521: settings.setExcludeWaitTime(getExcludeWaitTime());
0522: settings.setCPUProfilingType(getCPUProfilingType());
0523: settings.setInstrScheme(getInstrScheme());
0524: settings.setAbsoluteTimerOn(true);
0525: settings.setThreadCPUTimerOn(getThreadCPUTimerOn());
0526: settings
0527: .setInstrumentGetterSetterMethods(getInstrumentGetterSetterMethods());
0528: settings.setInstrumentEmptyMethods(getInstrumentEmptyMethods());
0529: settings.setInstrumentMethodInvoke(getInstrumentMethodInvoke());
0530: settings
0531: .setInstrumentSpawnedThreads(getInstrumentSpawnedThreads());
0532:
0533: if (getNProfiledThreadsLimit() > 0) {
0534: settings
0535: .setNProfiledThreadsLimit(getNProfiledThreadsLimit());
0536: } else {
0537: settings.setNProfiledThreadsLimit(Integer.MAX_VALUE); // zero or negative value means we do not limit it, just remember value for the UI
0538: }
0539:
0540: settings
0541: .setSortResultsByThreadCPUTime(getSortResultsByThreadCPUTime());
0542:
0543: settings.setSamplingInterval(getSamplingInterval());
0544:
0545: settings
0546: .setCodeRegionCPUResBufSize(getCodeRegionCPUResBufSize());
0547:
0548: settings
0549: .setRunGCOnGetResultsInMemoryProfiling(getRunGCOnGetResultsInMemoryProfiling());
0550: settings.setAllocTrackEvery(getAllocTrackEvery());
0551: settings.setAllocStackTraceLimit(getAllocStackTraceLimit());
0552:
0553: // Set rootMethods = new HashSet();
0554: // // Keep the order:
0555: // // 1. Root methods; 2. Marker methods
0556: // rootMethods.addAll(Arrays.asList(getInstrumentationRootMethods()));
0557: // rootMethods.addAll(Arrays.asList(getInstrumentationMarkerMethods()));
0558: // for(Iterator iter=rootMethods.iterator();iter.hasNext();) {
0559: // ((ClientUtils.SourceCodeSelection)iter.next()).setMarkerMethod(true);
0560: // }
0561: // settings.setInstrumentationRootMethods((ClientUtils.SourceCodeSelection[])rootMethods.toArray(new ClientUtils.SourceCodeSelection[rootMethods.size()]));
0562: settings
0563: .setInstrumentationRootMethods(getInstrumentationMethods());
0564:
0565: // Now applySettings the filters to the Engine's instrumentation filter
0566: final InstrumentationFilter instrumentationFilter = settings
0567: .getInstrumentationFilter();
0568: instrumentationFilter.clearFilter(); // lets start from scratch
0569:
0570: // No filter
0571: if (getSelectedInstrumentationFilter().equals(
0572: FilterUtils.NONE_FILTER)) {
0573: instrumentationFilter
0574: .setFilterType(InstrumentationFilter.INSTR_FILTER_NONE);
0575: instrumentationFilter.setFilterStrings(""); //NOI18N
0576:
0577: return;
0578: }
0579:
0580: // Quick Filter
0581: if (getSelectedInstrumentationFilter().equals(quickFilter)) {
0582: if (quickFilter.getFilterValue().length() > 0) {
0583: // Quick Filter defined
0584: instrumentationFilter
0585: .setFilterType((quickFilter.getFilterType() == SimpleFilter.SIMPLE_FILTER_EXCLUSIVE) ? InstrumentationFilter.INSTR_FILTER_EXCLUSIVE
0586: : InstrumentationFilter.INSTR_FILTER_INCLUSIVE);
0587: instrumentationFilter.setFilterStrings(quickFilter
0588: .getFilterValue());
0589: } else {
0590: // Quick Filter cancelled and no previous filter defined => filterType=INSTR_FILTER_NONE
0591: instrumentationFilter
0592: .setFilterType(InstrumentationFilter.INSTR_FILTER_NONE);
0593: instrumentationFilter.setFilterStrings(""); //NOI18N
0594: }
0595:
0596: return;
0597: }
0598:
0599: // Filter defined by ProjectTypeProfiler
0600: if (getSelectedInstrumentationFilter() instanceof SimpleFilter) {
0601: SimpleFilter ptpFilter = (SimpleFilter) getSelectedInstrumentationFilter();
0602: instrumentationFilter
0603: .setFilterType((ptpFilter.getFilterType() == SimpleFilter.SIMPLE_FILTER_EXCLUSIVE) ? InstrumentationFilter.INSTR_FILTER_EXCLUSIVE
0604: : InstrumentationFilter.INSTR_FILTER_INCLUSIVE);
0605: instrumentationFilter.setFilterStrings(ptpFilter
0606: .getFilterValue());
0607:
0608: return;
0609: }
0610:
0611: // Filter Set
0612: if (getSelectedInstrumentationFilter() instanceof FilterSet) {
0613: FilterSet filterSet = (FilterSet) getSelectedInstrumentationFilter();
0614: GlobalFilters globalFilters = Profiler.getDefault()
0615: .getGlobalFilters();
0616:
0617: // set filter type
0618: instrumentationFilter
0619: .setFilterType((filterSet.getFilterSetType() == FilterSet.FILTER_SET_EXCLUSIVE) ? InstrumentationFilter.INSTR_FILTER_EXCLUSIVE
0620: : InstrumentationFilter.INSTR_FILTER_INCLUSIVE);
0621:
0622: // set filter value
0623: final StringBuffer flatFilterStringsBuffer = new StringBuffer();
0624: final String[] activeGlobalFilters = filterSet
0625: .getActiveGlobalFilters();
0626:
0627: for (int i = 0; i < activeGlobalFilters.length; i++) {
0628: final String activeGlobalFilterValue = globalFilters
0629: .getFilterValue(activeGlobalFilters[i]);
0630:
0631: if (activeGlobalFilterValue != null) {
0632: flatFilterStringsBuffer
0633: .append(activeGlobalFilterValue);
0634: flatFilterStringsBuffer.append(" "); //NOI18N
0635: }
0636: }
0637:
0638: instrumentationFilter
0639: .setFilterStrings(flatFilterStringsBuffer
0640: .toString());
0641:
0642: return;
0643: }
0644:
0645: // Unknown or no filter
0646: instrumentationFilter
0647: .setFilterType(InstrumentationFilter.INSTR_FILTER_NONE);
0648: instrumentationFilter.setFilterStrings(""); //NOI18N
0649: }
0650:
0651: // -- Settings duplication -------------------------------------------------------------------------------------------
0652:
0653: /**
0654: * Copies only profiling settings (not session-related ones) into the given
0655: * ProfilingSettings instance
0656: *
0657: * @param settings the instance to copy the current settings into
0658: */
0659: public void copySettingsInto(final ProfilingSettings settings) {
0660: // settings.setIsPreset(isPreset()); // Preset flag should not be copied, copy isn't preset
0661: settings.setProfilingType(getProfilingType());
0662: settings.setOverrideGlobalSettings(getOverrideGlobalSettings());
0663: settings.setWorkingDir(getWorkingDir());
0664: settings.setJVMArgs(getJVMArgs());
0665: settings.setJavaPlatformName(getJavaPlatformName());
0666: settings
0667: .setThreadsMonitoringEnabled(getThreadsMonitoringEnabled());
0668: settings.setUseProfilingPoints(useProfilingPoints());
0669:
0670: settings.setExcludeWaitTime(getExcludeWaitTime());
0671: settings.setCPUProfilingType(getCPUProfilingType());
0672: settings.setInstrScheme(getInstrScheme());
0673: settings.setThreadCPUTimerOn(getThreadCPUTimerOn());
0674: settings
0675: .setInstrumentGetterSetterMethods(getInstrumentGetterSetterMethods());
0676: settings.setInstrumentEmptyMethods(getInstrumentEmptyMethods());
0677: settings.setInstrumentMethodInvoke(getInstrumentMethodInvoke());
0678: settings
0679: .setInstrumentSpawnedThreads(getInstrumentSpawnedThreads());
0680: settings.setNProfiledThreadsLimit(getNProfiledThreadsLimit());
0681: settings
0682: .setSortResultsByThreadCPUTime(getSortResultsByThreadCPUTime());
0683:
0684: settings.setSamplingInterval(getSamplingInterval());
0685: settings
0686: .setInstrumentationRootMethods(getInstrumentationRootMethods());
0687:
0688: settings.setCodeFragmentSelection(getCodeFragmentSelection());
0689: settings
0690: .setCodeRegionCPUResBufSize(getCodeRegionCPUResBufSize());
0691:
0692: settings
0693: .setRunGCOnGetResultsInMemoryProfiling(getRunGCOnGetResultsInMemoryProfiling());
0694: settings.setAllocTrackEvery(getAllocTrackEvery());
0695: settings.setAllocStackTraceLimit(getAllocStackTraceLimit());
0696:
0697: settings
0698: .setSelectedInstrumentationFilter(getSelectedInstrumentationFilter());
0699: settings.setQuickFilter(getQuickFilter());
0700:
0701: settings
0702: .setProfileUnderlyingFramework(getProfileUnderlyingFramework());
0703: }
0704:
0705: public String debug() {
0706: final StringBuffer sb = new StringBuffer();
0707: sb.append("isPreset: " + isPreset()); //NOI18N
0708: sb.append('\n'); //NOI18N
0709: sb.append("name: " + getSettingsName()); //NOI18N
0710: sb.append('\n'); //NOI18N
0711: sb.append("profilingType: " + getProfilingType()); //NOI18N
0712: sb.append('\n'); //NOI18N
0713: sb.append("overrideGlobalSettings: "
0714: + getOverrideGlobalSettings()); //NOI18N
0715: sb.append('\n'); //NOI18N
0716: sb.append("workingDir: " + getWorkingDir()); //NOI18N
0717: sb.append('\n'); //NOI18N
0718: sb.append("jvmArgs: " + getJVMArgs()); //NOI18N
0719: sb.append('\n'); //NOI18N
0720: sb.append("javaPlatform: "
0721: + ((getJavaPlatformName() == null) ? "<project>"
0722: : getJavaPlatformName())); //NOI18N
0723: sb.append('\n'); //NOI18N
0724: sb.append("threadsMonitoringEnabled: "
0725: + getThreadsMonitoringEnabled()); //NOI18N
0726: sb.append('\n'); //NOI18N
0727: sb.append("useProfilingPoints: " + useProfilingPoints()); // NOI18N
0728: sb.append('\n'); //NOI18N
0729: sb.append("excludeWaitTime: " + getExcludeWaitTime()); //NOI18N
0730: sb.append('\n'); //NOI18N
0731: sb.append("cpuProfilingType: " + getCPUProfilingType()); //NOI18N
0732: sb.append('\n'); //NOI18N
0733: sb.append("instrScheme: " + getInstrScheme()); //NOI18N
0734: sb.append('\n'); //NOI18N
0735: sb.append("threadCPUTimerOn: " + getThreadCPUTimerOn()); //NOI18N
0736: sb.append('\n'); //NOI18N
0737: sb.append("instrumentGetterSetterMethods: "
0738: + getInstrumentGetterSetterMethods()); //NOI18N
0739: sb.append('\n'); //NOI18N
0740: sb.append("instrumentEmptyMethods: "
0741: + getInstrumentEmptyMethods()); //NOI18N
0742: sb.append('\n'); //NOI18N
0743: sb.append("instrumentMethodInvoke: "
0744: + getInstrumentMethodInvoke()); //NOI18N
0745: sb.append('\n'); //NOI18N
0746: sb.append("instrumentSpawnedThreads: "
0747: + getInstrumentSpawnedThreads()); //NOI18N
0748: sb.append('\n'); //NOI18N
0749: sb.append("nProfiledThreadsLimit: "
0750: + getNProfiledThreadsLimit()); //NOI18N
0751: sb.append('\n'); //NOI18N
0752: sb.append("sortResultsByThreadCPUTime: "
0753: + getSortResultsByThreadCPUTime()); //NOI18N
0754: sb.append('\n'); //NOI18N
0755: sb.append("samplingInterval: " + getSamplingInterval()); //NOI18N
0756: sb.append('\n'); //NOI18N
0757: sb.append("instrumentationRootMethods: "
0758: + instrumentationRootMethods); //NOI18N
0759: sb.append('\n'); //NOI18N
0760: sb.append("codeFragmentSelection: "
0761: + getCodeFragmentSelection()); //NOI18N
0762: sb.append('\n'); //NOI18N
0763: sb.append("codeRegionCPUResBufSize: "
0764: + getCodeRegionCPUResBufSize()); //NOI18N
0765: sb.append('\n'); //NOI18N
0766: sb.append("runGCOnGetResultsInMemoryProfiling: "
0767: + getRunGCOnGetResultsInMemoryProfiling()); //NOI18N
0768: sb.append('\n'); //NOI18N
0769: sb.append("allocTrackEvery: " + getAllocTrackEvery()); //NOI18N
0770: sb.append('\n'); //NOI18N
0771: sb.append("allocStackTraceLimit: " + getAllocStackTraceLimit()); //NOI18N
0772: sb.append('\n'); //NOI18N
0773: sb.append("selectedInstrFilter: "
0774: + getSelectedInstrumentationFilter()); //NOI18N
0775: sb.append('\n'); //NOI18N
0776: sb.append("profileUnderlyingFramework: "
0777: + getProfileUnderlyingFramework()); //NOI18N
0778: sb.append('\n'); //NOI18N
0779:
0780: return sb.toString();
0781: }
0782:
0783: // TODO: just to keep backward compatibility, should be removed after code cleanup!!!
0784: public void load(final Map props) {
0785: load(props, ""); //NOI18N
0786: }
0787:
0788: public void load(final Map props, final String prefix) {
0789: setIsPreset(Boolean.valueOf(
0790: getProperty(props, prefix + PROP_IS_PRESET, "false"))
0791: .booleanValue()); //NOI18N
0792: setSettingsName(getProperty(props, prefix + PROP_SETTINGS_NAME,
0793: UNKNOWN_PROFILING_SETTINGS_NAME));
0794: setProfilingType(Integer.parseInt(getProperty(props, prefix
0795: + PROP_PROFILING_TYPE, "8"))); //NOI18N
0796: setOverrideGlobalSettings(Boolean.valueOf(
0797: getProperty(props, prefix
0798: + PROP_OVERRIDE_GLOBAL_SETTINGS, "false"))
0799: .booleanValue()); //NOI18N
0800: setWorkingDir(getProperty(props, prefix + PROP_WORKING_DIR, "")); //NOI18N
0801: setJVMArgs(getProperty(props, prefix + PROP_JVM_ARGS, "")); //NOI18N
0802:
0803: setJavaPlatformName(getProperty(props, prefix
0804: + PROP_JAVA_PLATFORM, null));
0805:
0806: setThreadsMonitoringEnabled(Boolean.valueOf(
0807: getProperty(props, prefix
0808: + PROP_THREADS_MONITORING_ENABLED, "false"))
0809: .booleanValue()); //NOI18N
0810:
0811: // CPU and Code Fragment common
0812: // default for exclude wait time is false, to reflect the setting stored in snapshots before the wait time
0813: // exclusion was introduced
0814: setExcludeWaitTime(Boolean.valueOf(
0815: getProperty(props, prefix + PROP_EXCLUDE_WAIT_TIME,
0816: "false")).booleanValue());
0817:
0818: // General CPU Profiling settings
0819: setCPUProfilingType(Integer.parseInt(getProperty(props, prefix
0820: + PROP_CPU_PROFILING_TYPE, "0"))); //NOI18N
0821: setInstrScheme(Integer.parseInt(getProperty(props, prefix
0822: + PROP_INSTR_SCHEME, "1"))); //NOI18N
0823: setThreadCPUTimerOn(Boolean.valueOf(
0824: getProperty(props, prefix + PROP_THREAD_CPU_TIMER_ON,
0825: "false")).booleanValue()); //NOI18N
0826: setInstrumentGetterSetterMethods(Boolean.valueOf(
0827: getProperty(props, prefix
0828: + PROP_INSTRUMENT_GETTER_SETTER_METHODS,
0829: "false")).booleanValue()); //NOI18N
0830: setInstrumentEmptyMethods(Boolean.valueOf(
0831: getProperty(props, prefix
0832: + PROP_INSTRUMENT_EMPTY_METHODS, "false"))
0833: .booleanValue()); //NOI18N
0834: setInstrumentMethodInvoke(Boolean.valueOf(
0835: getProperty(props, prefix
0836: + PROP_INSTRUMENT_METHOD_INVOKE, "true"))
0837: .booleanValue()); //NOI18N
0838: setInstrumentSpawnedThreads(Boolean.valueOf(
0839: getProperty(props, prefix
0840: + PROP_INSTRUMENT_SPAWNED_THREADS, "false"))
0841: .booleanValue()); //NOI18N
0842: setNProfiledThreadsLimit(Integer.parseInt(getProperty(props,
0843: prefix + PROP_N_PROFILED_THREADS_LIMIT, "32"))); //NOI18N
0844: setSortResultsByThreadCPUTime(Boolean
0845: .valueOf(
0846: getProperty(props, prefix
0847: + PROP_SORT_RESULTS_BY_THREAD_CPU_TIME,
0848: "false")).booleanValue()); //NOI18N
0849: setProfileUnderlyingFramework(Boolean.valueOf(
0850: getProperty(props, prefix
0851: + PROP_PROFILE_UNDERLYING_FRAMEWORK, "false"))
0852: .booleanValue()); //NOI18N
0853:
0854: Object iFilter = FilterUtils.loadFilter(props, prefix
0855: + PROP_SELECTED_INSTR_FILTER);
0856:
0857: if (iFilter == null) {
0858: iFilter = SimpleFilter.NO_FILTER; // if loading fails
0859: }
0860:
0861: setSelectedInstrumentationFilter(iFilter);
0862:
0863: SimpleFilter qFilter = (SimpleFilter) FilterUtils.loadFilter(
0864: props, prefix + PROP_QUICK_FILTER);
0865:
0866: if (qFilter == null) {
0867: qFilter = FilterUtils.QUICK_FILTER; // if loading fails
0868: }
0869:
0870: setQuickFilter(qFilter);
0871:
0872: if (getSelectedInstrumentationFilter() == null) {
0873: setSelectedInstrumentationFilter(SimpleFilter.NO_FILTER);
0874: }
0875:
0876: // CPU Profiling: Sampled
0877: setSamplingInterval(Integer.parseInt(getProperty(props, prefix
0878: + PROP_SAMPLING_INTERVAL, "10"))); //NOI18N
0879:
0880: // CPU Profiling: Part of Application
0881: final int instrumentationRootMethodsSize = Integer
0882: .parseInt(getProperty(props, prefix
0883: + PROP_INSTRUMENTATION_ROOT_METHODS_SIZE, "0")); //NOI18N
0884:
0885: for (int i = 0; i < instrumentationRootMethodsSize; i++) {
0886: final ClientUtils.SourceCodeSelection scs = ClientUtils
0887: .stringToSelection(getProperty(props, prefix
0888: + PROP_INSTRUMENTATION_ROOT_METHODS_PREFIX
0889: + i, null));
0890:
0891: if (scs != null) {
0892: instrumentationRootMethods.add(scs);
0893: }
0894: }
0895:
0896: final int instrumentationMarkerMethodsSize = Integer
0897: .parseInt(getProperty(props, prefix
0898: + PROP_INSTRUMENTATION_MARKER_METHODS_SIZE, "0")); //NOI18N
0899:
0900: for (int i = 0; i < instrumentationMarkerMethodsSize; i++) {
0901: final ClientUtils.SourceCodeSelection scs = ClientUtils
0902: .stringToSelection(getProperty(
0903: props,
0904: prefix
0905: + PROP_INSTRUMENTATION_MARKER_METHODS_PREFIX
0906: + i, null));
0907:
0908: if (scs != null) {
0909: scs.setMarkerMethod(true);
0910: instrumentationMarkerMethods.add(scs);
0911: }
0912: }
0913:
0914: // CPU Profiling: Code Fragment
0915: setCodeFragmentSelection(ClientUtils
0916: .stringToSelection(getProperty(props, prefix
0917: + PROP_FRAGMENT_SELECTION, ""))); //NOI18N
0918: setCodeRegionCPUResBufSize(Integer.parseInt(getProperty(props,
0919: prefix + PROP_CODE_REGION_CPU_RES_BUF_SIZE, "1000"))); //NOI18N
0920:
0921: // Memory profiling settings
0922: setRunGCOnGetResultsInMemoryProfiling(Boolean
0923: .valueOf(
0924: getProperty(
0925: props,
0926: prefix
0927: + PROP_RUN_GC_ON_GET_RESULTS_IN_MEMORY_PROFILING,
0928: "true")).booleanValue()); //NOI18N
0929: setAllocTrackEvery(Integer.parseInt(getProperty(props, prefix
0930: + PROP_OBJ_ALLOC_STACK_SAMPLING_INTERVAL, "10"))); //NOI18N
0931: setAllocStackTraceLimit(Integer.parseInt(getProperty(props,
0932: prefix + PROP_OBJ_ALLOC_STACK_SAMPLING_DEPTH, "-5"))); //NOI18N
0933:
0934: setUseProfilingPoints(Boolean.valueOf(
0935: getProperty(props, prefix
0936: + PROP_PROFILING_POINTS_ENABLED, "false"))
0937: .booleanValue()); //NOI18N
0938: }
0939:
0940: /** Only used for global storage of UI setting in SelectTaskPanel. TODO [ian]: refactor */
0941: public static void saveRootMethods(
0942: final ClientUtils.SourceCodeSelection[] roots,
0943: final Map props) {
0944: props.put(PROP_INSTRUMENTATION_ROOT_METHODS_SIZE, Integer
0945: .toString(roots.length));
0946:
0947: for (int i = 0; i < roots.length; i++) {
0948: props
0949: .put(
0950: PROP_INSTRUMENTATION_ROOT_METHODS_PREFIX
0951: + i,
0952: ClientUtils
0953: .selectionToString((ClientUtils.SourceCodeSelection) roots[i]));
0954: }
0955: }
0956:
0957: // TODO: just to keep backward compatibility, should be removed after code cleanup!!!
0958: public void store(final Map props) {
0959: store(props, ""); //NOI18N
0960: }
0961:
0962: public void store(final Map props, final String prefix) {
0963: props
0964: .put(prefix + PROP_IS_PRESET, Boolean
0965: .toString(isPreset()));
0966: props.put(prefix + PROP_SETTINGS_NAME, getSettingsName());
0967: props.put(prefix + PROP_PROFILING_TYPE, Integer
0968: .toString(getProfilingType()));
0969: props.put(prefix + PROP_OVERRIDE_GLOBAL_SETTINGS, Boolean
0970: .toString(getOverrideGlobalSettings()));
0971: props.put(prefix + PROP_WORKING_DIR, getWorkingDir());
0972: props.put(prefix + PROP_JVM_ARGS, getJVMArgs());
0973:
0974: if (getJavaPlatformName() != null) {
0975: props.put(prefix + PROP_JAVA_PLATFORM,
0976: getJavaPlatformName());
0977: }
0978:
0979: props.put(prefix + PROP_THREADS_MONITORING_ENABLED, Boolean
0980: .toString(getThreadsMonitoringEnabled()));
0981:
0982: // CPU and Code Fragment common
0983: props.put(prefix + PROP_EXCLUDE_WAIT_TIME, Boolean
0984: .toString(getExcludeWaitTime()));
0985:
0986: // General CPU Profiling settings
0987: props.put(prefix + PROP_CPU_PROFILING_TYPE, Integer
0988: .toString(getCPUProfilingType()));
0989: props.put(prefix + PROP_INSTR_SCHEME, Integer
0990: .toString(getInstrScheme()));
0991: props.put(prefix + PROP_THREAD_CPU_TIMER_ON, Boolean
0992: .toString(getThreadCPUTimerOn()));
0993: props.put(prefix + PROP_INSTRUMENT_GETTER_SETTER_METHODS,
0994: Boolean.toString(getInstrumentGetterSetterMethods()));
0995: props.put(prefix + PROP_INSTRUMENT_EMPTY_METHODS, Boolean
0996: .toString(getInstrumentEmptyMethods()));
0997: props.put(prefix + PROP_INSTRUMENT_METHOD_INVOKE, Boolean
0998: .toString(getInstrumentMethodInvoke()));
0999: props.put(prefix + PROP_INSTRUMENT_SPAWNED_THREADS, Boolean
1000: .toString(getInstrumentSpawnedThreads()));
1001: props.put(prefix + PROP_N_PROFILED_THREADS_LIMIT, Integer
1002: .toString(getNProfiledThreadsLimit()));
1003: props.put(prefix + PROP_SORT_RESULTS_BY_THREAD_CPU_TIME,
1004: Boolean.toString(getSortResultsByThreadCPUTime()));
1005:
1006: FilterUtils.storeFilter(props,
1007: getSelectedInstrumentationFilter(), prefix
1008: + PROP_SELECTED_INSTR_FILTER);
1009: FilterUtils.storeFilter(props, getQuickFilter(), prefix
1010: + PROP_QUICK_FILTER);
1011:
1012: props.put(prefix + PROP_PROFILE_UNDERLYING_FRAMEWORK, Boolean
1013: .toString(getProfileUnderlyingFramework()));
1014:
1015: // CPU Profiling: Sampled
1016: props.put(prefix + PROP_SAMPLING_INTERVAL, Integer
1017: .toString(getSamplingInterval()));
1018:
1019: // CPU Profiling: Part of Application
1020: props.put(prefix + PROP_INSTRUMENTATION_ROOT_METHODS_SIZE,
1021: Integer.toString(instrumentationRootMethods.size()));
1022:
1023: for (int i = 0; i < instrumentationRootMethods.size(); i++) {
1024: props
1025: .put(
1026: prefix
1027: + PROP_INSTRUMENTATION_ROOT_METHODS_PREFIX
1028: + i,
1029: ClientUtils
1030: .selectionToString((ClientUtils.SourceCodeSelection) instrumentationRootMethods
1031: .get(i)));
1032: }
1033:
1034: props.put(prefix + PROP_INSTRUMENTATION_MARKER_METHODS_SIZE,
1035: Integer.toString(instrumentationMarkerMethods.size()));
1036:
1037: for (int i = 0; i < instrumentationMarkerMethods.size(); i++) {
1038: props
1039: .put(
1040: prefix
1041: + PROP_INSTRUMENTATION_MARKER_METHODS_PREFIX
1042: + i,
1043: ClientUtils
1044: .selectionToString((ClientUtils.SourceCodeSelection) instrumentationMarkerMethods
1045: .get(i)));
1046: }
1047:
1048: // CPU Profiling: Code Fragment
1049: if (getCodeFragmentSelection() != null) {
1050: props.put(prefix + PROP_FRAGMENT_SELECTION, ClientUtils
1051: .selectionToString(getCodeFragmentSelection()));
1052: }
1053:
1054: props.put(prefix + PROP_CODE_REGION_CPU_RES_BUF_SIZE, Integer
1055: .toString(getCodeRegionCPUResBufSize()));
1056:
1057: // Memory profiling settings
1058: props
1059: .put(
1060: prefix
1061: + PROP_RUN_GC_ON_GET_RESULTS_IN_MEMORY_PROFILING,
1062: Boolean
1063: .toString(getRunGCOnGetResultsInMemoryProfiling()));
1064: props.put(prefix + PROP_OBJ_ALLOC_STACK_SAMPLING_INTERVAL,
1065: Integer.toString(getAllocTrackEvery()));
1066: props.put(prefix + PROP_OBJ_ALLOC_STACK_SAMPLING_DEPTH, Integer
1067: .toString(getAllocStackTraceLimit()));
1068:
1069: props.put(prefix + PROP_PROFILING_POINTS_ENABLED, Boolean
1070: .toString(useProfilingPoints()));
1071: }
1072:
1073: // -------------------------------------------------------------------------------------------------------------------
1074: // debug & print stuff
1075: public String toString() {
1076: return getSettingsName();
1077: }
1078:
1079: public boolean useProfilingPoints() {
1080: return useProfilingPoints;
1081: }
1082:
1083: static String getProperty(final Map props, final Object key,
1084: final String defaultValue) {
1085: final Object ret = props.get(key);
1086:
1087: return (ret != null) ? (String) ret : defaultValue;
1088: }
1089: }
|