mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-07 00:05:53 +02:00
[cleanup] get rid of warning messages
This commit is contained in:
parent
2af9a8635d
commit
f9210cdc57
7 changed files with 191 additions and 204 deletions
|
@ -24,13 +24,13 @@ public interface IRemoteSystemsLogging {
|
||||||
/**
|
/**
|
||||||
* Name of the key that controls the logging level.<br>
|
* Name of the key that controls the logging level.<br>
|
||||||
*/
|
*/
|
||||||
public static final String PLUGIN_ID = "org.eclipse.rse.logging";
|
public static final String PLUGIN_ID = "org.eclipse.rse.logging"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the key that controls the logging level.<br>
|
* Name of the key that controls the logging level.<br>
|
||||||
* (value is "debug_level").
|
* (value is "debug_level").
|
||||||
*/
|
*/
|
||||||
public static final String DEBUG_LEVEL = "debug_level";
|
public static final String DEBUG_LEVEL = "debug_level"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set debug_level to this value to get Error messages.<br>
|
* Set debug_level to this value to get Error messages.<br>
|
||||||
|
|
|
@ -146,7 +146,7 @@ public class Logger implements IPropertyChangeListener {
|
||||||
*/
|
*/
|
||||||
public synchronized void logError(String message, Throwable ex) {
|
public synchronized void logError(String message, Throwable ex) {
|
||||||
if (debug_level >= IRemoteSystemsLogging.LOG_ERROR) {
|
if (debug_level >= IRemoteSystemsLogging.LOG_ERROR) {
|
||||||
if (message == null) message = "";
|
if (message == null) message = ""; //$NON-NLS-1$
|
||||||
Status errorStatus = new Status(IStatus.ERROR, pluginId, IStatus.OK, message, ex);
|
Status errorStatus = new Status(IStatus.ERROR, pluginId, IStatus.OK, message, ex);
|
||||||
systemsPluginLog.log(errorStatus);
|
systemsPluginLog.log(errorStatus);
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ public class Logger implements IPropertyChangeListener {
|
||||||
*/
|
*/
|
||||||
public synchronized void logInfo(String message, Throwable ex) {
|
public synchronized void logInfo(String message, Throwable ex) {
|
||||||
if (debug_level >= IRemoteSystemsLogging.LOG_INFO) {
|
if (debug_level >= IRemoteSystemsLogging.LOG_INFO) {
|
||||||
if (message == null) message = "";
|
if (message == null) message = ""; //$NON-NLS-1$
|
||||||
Status infoStatus = new Status(IStatus.INFO, pluginId, IStatus.OK, message, ex);
|
Status infoStatus = new Status(IStatus.INFO, pluginId, IStatus.OK, message, ex);
|
||||||
systemsPluginLog.log(infoStatus);
|
systemsPluginLog.log(infoStatus);
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ public class Logger implements IPropertyChangeListener {
|
||||||
*/
|
*/
|
||||||
public synchronized void logWarning(String message, Throwable ex) {
|
public synchronized void logWarning(String message, Throwable ex) {
|
||||||
if (debug_level >= IRemoteSystemsLogging.LOG_WARNING) {
|
if (debug_level >= IRemoteSystemsLogging.LOG_WARNING) {
|
||||||
if (message == null) message = "";
|
if (message == null) message = ""; //$NON-NLS-1$
|
||||||
Status warningStatus = new Status(IStatus.WARNING, pluginId, IStatus.OK, message, ex);
|
Status warningStatus = new Status(IStatus.WARNING, pluginId, IStatus.OK, message, ex);
|
||||||
systemsPluginLog.log(warningStatus);
|
systemsPluginLog.log(warningStatus);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ class RemoteSystemLogListener implements ILogListener, IPropertyChangeListener {
|
||||||
* @param plugin The plugin for which to create a log listener.
|
* @param plugin The plugin for which to create a log listener.
|
||||||
*/
|
*/
|
||||||
public RemoteSystemLogListener(Plugin plugin) {
|
public RemoteSystemLogListener(Plugin plugin) {
|
||||||
IPath path = plugin.getStateLocation().addTrailingSeparator().append(".log");
|
IPath path = plugin.getStateLocation().addTrailingSeparator().append(".log"); //$NON-NLS-1$
|
||||||
outputFile = path.toFile();
|
outputFile = path.toFile();
|
||||||
if ((outputFile != null) && (outputFile.exists())) {
|
if ((outputFile != null) && (outputFile.exists())) {
|
||||||
outputFile.delete();
|
outputFile.delete();
|
||||||
|
@ -60,7 +60,7 @@ class RemoteSystemLogListener implements ILogListener, IPropertyChangeListener {
|
||||||
log = new PrintWriter(new BufferedWriter(new FileWriter(outputFile.toString(), true)), true);
|
log = new PrintWriter(new BufferedWriter(new FileWriter(outputFile.toString(), true)), true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log = null;
|
log = null;
|
||||||
System.err.println("Exception in RemoteSystemLogListener.initialize(): " + e.getMessage());
|
System.err.println("Exception in RemoteSystemLogListener.initialize(): " + e.getMessage()); //$NON-NLS-1$
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,18 +74,18 @@ class RemoteSystemLogListener implements ILogListener, IPropertyChangeListener {
|
||||||
log.println(date);
|
log.println(date);
|
||||||
int severity = status.getSeverity();
|
int severity = status.getSeverity();
|
||||||
if (severity == IStatus.ERROR) {
|
if (severity == IStatus.ERROR) {
|
||||||
log.print("ERROR");
|
log.print("ERROR"); //$NON-NLS-1$
|
||||||
} else if (severity == IStatus.WARNING) {
|
} else if (severity == IStatus.WARNING) {
|
||||||
log.print("WARNING");
|
log.print("WARNING"); //$NON-NLS-1$
|
||||||
} else if (severity == IStatus.INFO) {
|
} else if (severity == IStatus.INFO) {
|
||||||
log.print("INFO");
|
log.print("INFO"); //$NON-NLS-1$
|
||||||
} else if (severity == IStatus.OK) {
|
} else if (severity == IStatus.OK) {
|
||||||
log.print("DEBUG");
|
log.print("DEBUG"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
log.print(" ");
|
log.print(" "); //$NON-NLS-1$
|
||||||
log.print(status.getPlugin());
|
log.print(status.getPlugin());
|
||||||
log.print(" ");
|
log.print(" "); //$NON-NLS-1$
|
||||||
log.println(status.getMessage());
|
log.println(status.getMessage());
|
||||||
if (status.getException() != null) status.getException().printStackTrace(log);
|
if (status.getException() != null) status.getException().printStackTrace(log);
|
||||||
if (status.isMultiStatus()) {
|
if (status.isMultiStatus()) {
|
||||||
|
@ -94,7 +94,7 @@ class RemoteSystemLogListener implements ILogListener, IPropertyChangeListener {
|
||||||
loggingChild(children[i]);
|
loggingChild(children[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.println("--------------------------------------------");
|
log.println("--------------------------------------------"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ class RemoteSystemLogListener implements ILogListener, IPropertyChangeListener {
|
||||||
if (log == null)
|
if (log == null)
|
||||||
return;
|
return;
|
||||||
else {
|
else {
|
||||||
log.print("\t\t");
|
log.print("\t\t"); //$NON-NLS-1$
|
||||||
log.println(status.getMessage());
|
log.println(status.getMessage());
|
||||||
if (status.getException() != null) status.getException().printStackTrace(log);
|
if (status.getException() != null) status.getException().printStackTrace(log);
|
||||||
if (status.isMultiStatus()) {
|
if (status.isMultiStatus()) {
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class RemoteSystemsLoggingPlugin extends Plugin {
|
||||||
ResourceBundle bundle = RemoteSystemsLoggingPlugin.getDefault().getResourceBundle();
|
ResourceBundle bundle = RemoteSystemsLoggingPlugin.getDefault().getResourceBundle();
|
||||||
return bundle.getString(key);
|
return bundle.getString(key);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
out.logError("could not get resource string for: " + key, e);
|
out.logError("could not get resource string for: " + key, e); //$NON-NLS-1$
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,12 +70,12 @@ public class RemoteSystemsLoggingPlugin extends Plugin {
|
||||||
public ResourceBundle getResourceBundle() {
|
public ResourceBundle getResourceBundle() {
|
||||||
if (resourceBundle == null) {
|
if (resourceBundle == null) {
|
||||||
try {
|
try {
|
||||||
IPath path = new Path("$nl$/RemoteSystemsLogging.properties");
|
IPath path = new Path("$nl$/RemoteSystemsLogging.properties"); //$NON-NLS-1$
|
||||||
URL url = FileLocator.find(getBundle(), path, null);
|
URL url = FileLocator.find(getBundle(), path, null);
|
||||||
resourceBundle = new PropertyResourceBundle(url.openStream());
|
resourceBundle = new PropertyResourceBundle(url.openStream());
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
resourceBundle = null;
|
resourceBundle = null;
|
||||||
out.logInfo("RemoteSystemsLoggingPlugin - unable to log resourcebundle");
|
out.logInfo("RemoteSystemsLoggingPlugin - unable to log resourcebundle"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return resourceBundle;
|
return resourceBundle;
|
||||||
|
@ -87,7 +87,7 @@ public class RemoteSystemsLoggingPlugin extends Plugin {
|
||||||
public void start(BundleContext context) throws Exception {
|
public void start(BundleContext context) throws Exception {
|
||||||
super.start(context);
|
super.start(context);
|
||||||
out = LoggerFactory.getLogger(this);
|
out = LoggerFactory.getLogger(this);
|
||||||
out.logInfo("loading RemoteSystemsLoggingPlugin class.");
|
out.logInfo("loading RemoteSystemsLoggingPlugin class."); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -19,12 +19,15 @@ package org.eclipse.rse.logging.performance;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
import java.text.MessageFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.EmptyStackException;
|
import java.util.EmptyStackException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
@ -50,52 +53,51 @@ import org.w3c.dom.Element;
|
||||||
* A performance measurement class for benchmarking.
|
* A performance measurement class for benchmarking.
|
||||||
* This performance framework provides stopwatch functions
|
* This performance framework provides stopwatch functions
|
||||||
* for calculating elapsed time for an operation.
|
* for calculating elapsed time for an operation.
|
||||||
|
* <p>
|
||||||
|
* This class should be used only at development time since
|
||||||
|
* it prints to System.out
|
||||||
|
* and contains non-translated strings.
|
||||||
|
* <p>
|
||||||
|
* It is highly likely that this class will be deprecated in 2.0.
|
||||||
|
* Use TPTPs tools for performance monitoring and logging.
|
||||||
|
* <pre>
|
||||||
|
* Usage example
|
||||||
|
* Method_A {
|
||||||
|
* String key = PerformanceLogger.register("RSE","WDSC","5120");
|
||||||
|
* PerformanceLogger.start(key, "OP1"); //CallerID is OP1
|
||||||
|
* Method_B();
|
||||||
|
* PerformanceLogger.stop(key);
|
||||||
|
* }
|
||||||
*
|
*
|
||||||
* Usuage example
|
* Method_B {
|
||||||
* Method_A {
|
* PerformanceLogger.start("RSE"); //"RSE" component, CalleID="class.method"
|
||||||
* String key = PerformanceLogger.register("RSE","WDSC","5120");
|
* // Do something
|
||||||
* PerformanceLogger.start(key, "OP1"); //CallerID is OP1
|
* PerformanceLogger.stop("RSE");
|
||||||
* Method_B();
|
* }
|
||||||
* PerformanceLogger.stop(key);
|
|
||||||
* }
|
|
||||||
*
|
*
|
||||||
* Method_B {
|
* Method_C {
|
||||||
* PerformanceLogger.start("RSE"); //"RSE" component, CalleID="class.method"
|
|
||||||
* // Do something
|
|
||||||
* PerformanceLogger.stop("RSE");
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* Method_C {
|
|
||||||
* PerformanceLogger.start(); //Use the default component for recording
|
* PerformanceLogger.start(); //Use the default component for recording
|
||||||
* // Do something
|
* // Do something
|
||||||
* PerformanceLogger.stop();
|
* PerformanceLogger.stop();
|
||||||
* }
|
* }
|
||||||
|
*</pre>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class PerformanceLogger {
|
public class PerformanceLogger {
|
||||||
|
|
||||||
public final static boolean _ENABLE_PERFORMANCE_LOGGING_IBM_INTERNAL_ = false;
|
public final static boolean _ENABLE_PERFORMANCE_LOGGING_IBM_INTERNAL_ = false;
|
||||||
|
|
||||||
public final static int OPTION_GET_ALL = 1;
|
public final static int OPTION_GET_ALL = 1;
|
||||||
|
|
||||||
public final static int OPTION_GET_FEATURE = 2;
|
public final static int OPTION_GET_FEATURE = 2;
|
||||||
|
|
||||||
public final static int OPTION_GET_VERSION = 3;
|
public final static int OPTION_GET_VERSION = 3;
|
||||||
|
private final static Object[] EMPTY = {};
|
||||||
final static String ELEMENT_TASK = "Task";
|
private final static String ELEMENT_TASK = "Task"; //$NON-NLS-1$
|
||||||
|
private final static String ATTRIBUTE_NAME_TASKID = "CallerID"; //$NON-NLS-1$
|
||||||
final static String ATTRIBUTE_NAME_TASKID = "CallerID";
|
private final static String DEFAULT_COMPONENT = "_PERFORMANCELOGGER_"; //$NON-NLS-1$
|
||||||
|
private static boolean ENABLE_PERFORMANCE_LOGGING = false; /*for user logging enabling */
|
||||||
final static String DEFAULT_COMPONENT = "_PERFORMANCELOGGER_";
|
|
||||||
|
|
||||||
static boolean ENABLE_PERFORMANCE_LOGGING = false; /*for user logging enabling*/
|
|
||||||
|
|
||||||
//static long currentAssignedID = -1;
|
//static long currentAssignedID = -1;
|
||||||
static long samplingTime = -1; /* Elapsed time for normalization operatin */
|
private static long samplingTime = -1; /* Elapsed time for normalization operation */
|
||||||
|
private static boolean _initialized = false;
|
||||||
static boolean _initialized = false;
|
private static HashMap perfLogRegistry = new HashMap();
|
||||||
|
|
||||||
static HashMap perfLogRegistry = new HashMap();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Static initializer to normalize this logger.
|
* Static initializer to normalize this logger.
|
||||||
|
@ -106,37 +108,23 @@ public class PerformanceLogger {
|
||||||
|
|
||||||
static class StartData {
|
static class StartData {
|
||||||
long startTime = -1;
|
long startTime = -1;
|
||||||
|
|
||||||
long stopTime = -1;
|
long stopTime = -1;
|
||||||
|
|
||||||
String userID = null;
|
String userID = null;
|
||||||
|
|
||||||
String startThread = null;
|
String startThread = null;
|
||||||
|
|
||||||
String startMethod = null;
|
String startMethod = null;
|
||||||
|
|
||||||
String stopThread = null;
|
String stopThread = null;
|
||||||
|
|
||||||
String stopMethod = null;
|
String stopMethod = null;
|
||||||
|
|
||||||
Element node = null;
|
Element node = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ComponentData {
|
class ComponentData {
|
||||||
String component = null;
|
String component = null;
|
||||||
|
|
||||||
String timeStamp = null;
|
String timeStamp = null;
|
||||||
|
|
||||||
String feature = null;
|
String feature = null;
|
||||||
|
|
||||||
String version = null;
|
String version = null;
|
||||||
|
|
||||||
String XMLFileID = null;
|
String XMLFileID = null;
|
||||||
|
|
||||||
File XMLFile = null;
|
File XMLFile = null;
|
||||||
|
|
||||||
Document doc = null;
|
Document doc = null;
|
||||||
|
|
||||||
Stack taskStack = new Stack();
|
Stack taskStack = new Stack();
|
||||||
|
|
||||||
ComponentData(String comp_id) {
|
ComponentData(String comp_id) {
|
||||||
|
@ -144,16 +132,25 @@ public class PerformanceLogger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void printMessage(String message, Object[] data) {
|
||||||
|
System.out.println(MessageFormat.format(message, data));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void printMessage(String message, Object value) {
|
||||||
|
printMessage(message, new Object[] {value});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void printMessage(String message) {
|
||||||
|
printMessage(message, EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable performance logging
|
* Enable performance logging
|
||||||
* The flag ENABLE_PERFORMANCE_LOGGING is enabled(true or false)
|
* The flag ENABLE_PERFORMANCE_LOGGING is enabled(true or false)
|
||||||
* @param enable : true or false
|
* @param enable true or false
|
||||||
*/
|
*/
|
||||||
public static void enablePerformanceLogging(boolean enable) {
|
public static void enablePerformanceLogging(boolean enable) {
|
||||||
if (enable)
|
ENABLE_PERFORMANCE_LOGGING = enable;
|
||||||
ENABLE_PERFORMANCE_LOGGING = true;
|
|
||||||
else
|
|
||||||
ENABLE_PERFORMANCE_LOGGING = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -164,24 +161,18 @@ public class PerformanceLogger {
|
||||||
return ENABLE_PERFORMANCE_LOGGING;
|
return ENABLE_PERFORMANCE_LOGGING;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public static String register(String comp_id) : registering a component using default
|
/** public static String register(String comp_id) : registering a component using default
|
||||||
* @param
|
* @param comp_id Component to be registered
|
||||||
* - comp_id: Component to be registered
|
* @return component registered with no product info
|
||||||
* @return
|
|
||||||
* compont comp_id registered with no product info
|
|
||||||
*/
|
*/
|
||||||
public static String register(String comp_id) {
|
public static String register(String comp_id) {
|
||||||
return register(comp_id, "", "");
|
return register(comp_id, "", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public static String register(String feature, String version) : method for registering a component using default
|
/** Registers component using default component id
|
||||||
* @param
|
* @param feature Identifier for Product Feature attribute in XML
|
||||||
* - feature: Identifier for Product Feature attribute in XML
|
* @param version Identifier for Product Version attribute in XML
|
||||||
* - version: Identifier for Product Version attribute in XML
|
* @return default component key
|
||||||
* @return
|
|
||||||
* - return default component key
|
|
||||||
* - Default component XML file created
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public static String register(String feature, String version) {
|
public static String register(String feature, String version) {
|
||||||
return register(DEFAULT_COMPONENT, feature, version);
|
return register(DEFAULT_COMPONENT, feature, version);
|
||||||
|
@ -198,12 +189,12 @@ public class PerformanceLogger {
|
||||||
public static String register(String comp_id, String feature, String version) {
|
public static String register(String comp_id, String feature, String version) {
|
||||||
|
|
||||||
if ((comp_id == null) || (comp_id.length() == 0)) {
|
if ((comp_id == null) || (comp_id.length() == 0)) {
|
||||||
System.out.println("PerformanceLogger:register(): Cannot register null component id.");
|
printMessage("PerformanceLogger:register(): Cannot register null or empty component id."); //$NON-NLS-1$
|
||||||
return comp_id;
|
return comp_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (perfLogRegistry.containsKey(comp_id)) {
|
if (perfLogRegistry.containsKey(comp_id)) {
|
||||||
System.out.println("PerformanceLogger:register(): component \"" + comp_id + "\" already registered");
|
printMessage("PerformanceLogger:register(): component {0} already registered", comp_id); //$NON-NLS-1$
|
||||||
return comp_id;
|
return comp_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,8 +202,10 @@ public class PerformanceLogger {
|
||||||
|
|
||||||
Calendar time = Calendar.getInstance();
|
Calendar time = Calendar.getInstance();
|
||||||
compData.timeStamp = time.getTime().toString();
|
compData.timeStamp = time.getTime().toString();
|
||||||
String userID = System.getProperty("user.name");
|
String userID = System.getProperty("user.name"); //$NON-NLS-1$
|
||||||
compData.XMLFileID = comp_id + "_" + userID + "_" + feature.replace(' ', '_') + "_" + version.replace(' ', '_') + "_perf." + compData.timeStamp.replace(' ', '_').replace(':', '_') + ".xml";
|
String idTemplate = "{0}_{1}_{2}_{3}_perf.{4}.xml"; //$NON-NLS-1$
|
||||||
|
String id = MessageFormat.format(idTemplate, new Object[] {comp_id, userID, feature, version, compData.timeStamp});
|
||||||
|
compData.XMLFileID = id.replace(' ', '_').replace(':', '_');
|
||||||
compData.XMLFile = new File(compData.XMLFileID);
|
compData.XMLFile = new File(compData.XMLFileID);
|
||||||
compData.feature = feature;
|
compData.feature = feature;
|
||||||
compData.version = version;
|
compData.version = version;
|
||||||
|
@ -220,7 +213,7 @@ public class PerformanceLogger {
|
||||||
compData.taskStack = new Stack();
|
compData.taskStack = new Stack();
|
||||||
perfLogRegistry.put(comp_id, compData);
|
perfLogRegistry.put(comp_id, compData);
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
System.out.println("SystemPerformanceLogger: XML file created is \"" + compData.XMLFile.getAbsolutePath() + "\".");
|
printMessage("PerformanceLogger: XML file created is {0}.", compData.XMLFile.getAbsolutePath()); //$NON-NLS-1$
|
||||||
return comp_id;
|
return comp_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +224,7 @@ public class PerformanceLogger {
|
||||||
*/
|
*/
|
||||||
public static void deRegister() {
|
public static void deRegister() {
|
||||||
perfLogRegistry.remove(DEFAULT_COMPONENT);
|
perfLogRegistry.remove(DEFAULT_COMPONENT);
|
||||||
System.out.println("SystemPerformanceLogger: default component de-registered");
|
printMessage("SystemPerformanceLogger: default component de-registered"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -242,20 +235,20 @@ public class PerformanceLogger {
|
||||||
*/
|
*/
|
||||||
public static void deRegister(String key) {
|
public static void deRegister(String key) {
|
||||||
perfLogRegistry.remove(key);
|
perfLogRegistry.remove(key);
|
||||||
System.out.println("SystemPerformanceLogger: component \"" + key + "\" de-registered");
|
printMessage("SystemPerformanceLogger: component {0} de-registered", key); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the normalization unit for this run.based on a standard method for class instance initialization.
|
* Set the normalization unit for this run. Based on a standard method for class instance initialization.
|
||||||
* @return a string containing the unit.
|
* @return a string containing the unit.
|
||||||
*/
|
*/
|
||||||
public static String normalize() {
|
public static String normalize() {
|
||||||
/*
|
/*
|
||||||
* Execute some standard code and time it to generate our normalization interval.
|
* Execute some standard code and time it to generate our normalization interval.
|
||||||
* Return the value to attempt to make it is not optimized by the compiler.
|
* Return the value to attempt to make sure it is not optimized by the compiler.
|
||||||
*/
|
*/
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
Double q = null;
|
Double q = new Double(0);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int n = 1000000;
|
int n = 1000000;
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
|
@ -266,7 +259,8 @@ public class PerformanceLogger {
|
||||||
double val = q.doubleValue() / i;
|
double val = q.doubleValue() / i;
|
||||||
long stopTime = System.currentTimeMillis();
|
long stopTime = System.currentTimeMillis();
|
||||||
samplingTime = stopTime - startTime;
|
samplingTime = stopTime - startTime;
|
||||||
String result = "SystemPerformanceLogger::Normalization Elapsed time = " + samplingTime + " " + val;
|
String template = "SystemPerformanceLogger::Normalization Elapsed time = {0} {1}"; //$NON-NLS-1$
|
||||||
|
String result = MessageFormat.format(template, new Object[] {new Long(samplingTime), new Double(val)});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,11 +272,10 @@ public class PerformanceLogger {
|
||||||
*/
|
*/
|
||||||
public static long start() {
|
public static long start() {
|
||||||
if (_initialized == false) {
|
if (_initialized == false) {
|
||||||
register(DEFAULT_COMPONENT, "", "");
|
register(DEFAULT_COMPONENT, "", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
/*Use the class method name for CallerID*/
|
/*Use the class method name for CallerID*/
|
||||||
String methodPath = getMethodName(true);
|
String methodPath = getMethodName(true);
|
||||||
|
|
||||||
return start(DEFAULT_COMPONENT, methodPath);
|
return start(DEFAULT_COMPONENT, methodPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,7 +287,6 @@ public class PerformanceLogger {
|
||||||
public static long start(String comp_id) {
|
public static long start(String comp_id) {
|
||||||
String methodPath = getMethodName(true);
|
String methodPath = getMethodName(true);
|
||||||
return start(comp_id, methodPath);
|
return start(comp_id, methodPath);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -308,7 +300,7 @@ public class PerformanceLogger {
|
||||||
public static long start(String comp_id, String call_id) {
|
public static long start(String comp_id, String call_id) {
|
||||||
|
|
||||||
if (perfLogRegistry.containsKey(comp_id) == false) {
|
if (perfLogRegistry.containsKey(comp_id) == false) {
|
||||||
System.out.println("PerformanceLogger:start(): component \"" + comp_id + "\" not registered");
|
printMessage("PerformanceLogger:start(): component {0} not registered", comp_id); //$NON-NLS-1$
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,8 +318,8 @@ public class PerformanceLogger {
|
||||||
Element root = cd.doc.getDocumentElement();
|
Element root = cd.doc.getDocumentElement();
|
||||||
Element task = cd.doc.createElement(ELEMENT_TASK);
|
Element task = cd.doc.createElement(ELEMENT_TASK);
|
||||||
task.setAttribute(ATTRIBUTE_NAME_TASKID, td.userID);
|
task.setAttribute(ATTRIBUTE_NAME_TASKID, td.userID);
|
||||||
task.setAttribute("StartAt", td.startMethod);
|
task.setAttribute("StartAt", td.startMethod); //$NON-NLS-1$
|
||||||
task.setAttribute("StartThread", td.startThread);
|
task.setAttribute("StartThread", td.startThread); //$NON-NLS-1$
|
||||||
|
|
||||||
td.node = task;
|
td.node = task;
|
||||||
|
|
||||||
|
@ -340,7 +332,7 @@ public class PerformanceLogger {
|
||||||
sd.node.appendChild(task);
|
sd.node.appendChild(task);
|
||||||
}
|
}
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
System.out.println("PerformanceLogger::updateXMLFileatStart DOM Error:" + e.toString());
|
printMessage("PerformanceLogger::updateXMLFileatStart DOM Error: {0}", e); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Read the current time save it on stack */
|
/*Read the current time save it on stack */
|
||||||
|
@ -369,23 +361,21 @@ public class PerformanceLogger {
|
||||||
long st = System.currentTimeMillis();
|
long st = System.currentTimeMillis();
|
||||||
ComponentData cd = (ComponentData) perfLogRegistry.get(comp_id);
|
ComponentData cd = (ComponentData) perfLogRegistry.get(comp_id);
|
||||||
if (cd == null) {
|
if (cd == null) {
|
||||||
System.out.println("SystemPerformanceLogger::stop(): invalid registration key");
|
printMessage("SystemPerformanceLogger::stop(): invalid registration key"); //$NON-NLS-1$
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
StartData td = null;
|
long result = 0;
|
||||||
try {
|
try {
|
||||||
td = (StartData) cd.taskStack.pop();
|
StartData td = (StartData) cd.taskStack.pop();
|
||||||
td.stopTime = st;
|
td.stopTime = st;
|
||||||
td.stopThread = Thread.currentThread().toString();
|
td.stopThread = Thread.currentThread().toString();
|
||||||
td.stopMethod = getMethodName(false);
|
td.stopMethod = getMethodName(false);
|
||||||
updateXMLFileAtStop(cd, td);
|
updateXMLFileAtStop(cd, td);
|
||||||
|
result = td.stopTime;
|
||||||
//System.out.println("SystemPerformanceLogger::stop(): timer \"" + td.userID + "\" stopped. Elapsed time = " +
|
|
||||||
// (td.stopTime-td.startTime) + " millis.");
|
|
||||||
} catch (EmptyStackException e) {
|
} catch (EmptyStackException e) {
|
||||||
System.out.println("SystemPerformanceLogger:: Probably too many stop() function calls. - " + e);
|
printMessage("SystemPerformanceLogger:: Probably too many stop() function calls. - {0}", e); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
return td.stopTime;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -394,46 +384,42 @@ public class PerformanceLogger {
|
||||||
*/
|
*/
|
||||||
private static void generateXMLFile(ComponentData cd) {
|
private static void generateXMLFile(ComponentData cd) {
|
||||||
try {
|
try {
|
||||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(cd.XMLFile), "UTF8"));
|
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(cd.XMLFile), "UTF8")); //$NON-NLS-1$
|
||||||
// DOMImplementation impl = new DOMImplementationImpl();
|
// DOMImplementation impl = new DOMImplementationImpl();
|
||||||
// cd.doc = impl.createDocument(null, "Benchmark", null);
|
// cd.doc = impl.createDocument(null, "Benchmark", null);
|
||||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
DocumentBuilder builder = null;
|
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||||
try {
|
|
||||||
builder = factory.newDocumentBuilder();
|
|
||||||
} catch (ParserConfigurationException e1) {
|
|
||||||
}
|
|
||||||
DOMImplementation impl = builder.getDOMImplementation();
|
DOMImplementation impl = builder.getDOMImplementation();
|
||||||
cd.doc = impl.createDocument(null, "Benchmark", null);
|
cd.doc = impl.createDocument(null, "Benchmark", null); //$NON-NLS-1$
|
||||||
// get root element and set attributes
|
// get root element and set attributes
|
||||||
Element root = cd.doc.getDocumentElement();
|
Element root = cd.doc.getDocumentElement();
|
||||||
root.setAttribute("BenchmarkID", cd.XMLFileID);
|
root.setAttribute("BenchmarkID", cd.XMLFileID); //$NON-NLS-1$
|
||||||
root.setAttribute("TimeStamp", cd.timeStamp);
|
root.setAttribute("TimeStamp", cd.timeStamp); //$NON-NLS-1$
|
||||||
|
|
||||||
Element system = cd.doc.createElement("System");
|
Element system = cd.doc.createElement("System"); //$NON-NLS-1$
|
||||||
Element product = cd.doc.createElement("Product");
|
Element product = cd.doc.createElement("Product"); //$NON-NLS-1$
|
||||||
|
|
||||||
product.setAttribute("Feature", cd.feature);
|
product.setAttribute("Feature", cd.feature); //$NON-NLS-1$
|
||||||
product.setAttribute("Version", cd.version);
|
product.setAttribute("Version", cd.version); //$NON-NLS-1$
|
||||||
root.appendChild(product);
|
root.appendChild(product);
|
||||||
|
|
||||||
system.setAttribute("OSName", System.getProperty("os.name"));
|
system.setAttribute("OSName", System.getProperty("os.name")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
system.setAttribute("OSVersion", System.getProperty("os.version"));
|
system.setAttribute("OSVersion", System.getProperty("os.version")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
system.setAttribute("JavaVersion", System.getProperty("java.version"));
|
system.setAttribute("JavaVersion", System.getProperty("java.version")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
system.setAttribute("JavaVMVersion", System.getProperty("java.vm.version"));
|
system.setAttribute("JavaVMVersion", System.getProperty("java.vm.version")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
system.setAttribute("JavaClassPath", System.getProperty("java.class.path"));
|
system.setAttribute("JavaClassPath", System.getProperty("java.class.path")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
system.setAttribute("JavaLibraryPath", System.getProperty("java.library.path"));
|
system.setAttribute("JavaLibraryPath", System.getProperty("java.library.path")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
root.appendChild(system);
|
root.appendChild(system);
|
||||||
|
|
||||||
Element norm = cd.doc.createElement("_NORMALIZATION_VALUES");
|
Element norm = cd.doc.createElement("_NORMALIZATION_VALUES"); //$NON-NLS-1$
|
||||||
Long ems = new Long(samplingTime);
|
Long ems = new Long(samplingTime);
|
||||||
norm.setAttribute("ElapsedTime", ems.toString());
|
norm.setAttribute("ElapsedTime", ems.toString()); //$NON-NLS-1$
|
||||||
root.appendChild(norm);
|
root.appendChild(norm);
|
||||||
|
|
||||||
/* Insert comments for Task tag */
|
/* Insert comments for Task tag */
|
||||||
Comment cmt1 = cd.doc.createComment("Each Task element represents one start/stop timer operation");
|
Comment cmt1 = cd.doc.createComment("Each Task element represents one start/stop timer operation"); //$NON-NLS-1$
|
||||||
Comment cmt2 = cd.doc.createComment("Time recorded is in milliseconds");
|
Comment cmt2 = cd.doc.createComment("Time recorded is in milliseconds"); //$NON-NLS-1$
|
||||||
Comment cmt3 = cd.doc.createComment("NormalizedFactor is the performance indicator. A larger value than the previous run might indicate performance degradation.");
|
Comment cmt3 = cd.doc.createComment("NormalizedFactor is the performance indicator. A larger value than the previous run might indicate performance degradation."); //$NON-NLS-1$
|
||||||
root.appendChild(cmt1);
|
root.appendChild(cmt1);
|
||||||
root.appendChild(cmt2);
|
root.appendChild(cmt2);
|
||||||
root.appendChild(cmt3);
|
root.appendChild(cmt3);
|
||||||
|
@ -442,7 +428,7 @@ public class PerformanceLogger {
|
||||||
Source source = new DOMSource(cd.doc);
|
Source source = new DOMSource(cd.doc);
|
||||||
Result result = new StreamResult(writer);
|
Result result = new StreamResult(writer);
|
||||||
Transformer t = TransformerFactory.newInstance().newTransformer();
|
Transformer t = TransformerFactory.newInstance().newTransformer();
|
||||||
t.setOutputProperty(OutputKeys.INDENT, "yes");
|
t.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
|
||||||
t.transform(source, result);
|
t.transform(source, result);
|
||||||
} catch (TransformerConfigurationException e2) {
|
} catch (TransformerConfigurationException e2) {
|
||||||
} catch (TransformerFactoryConfigurationError e2) {
|
} catch (TransformerFactoryConfigurationError e2) {
|
||||||
|
@ -458,10 +444,12 @@ public class PerformanceLogger {
|
||||||
// serializer.serialize(cd.doc);
|
// serializer.serialize(cd.doc);
|
||||||
// writer.close();
|
// writer.close();
|
||||||
|
|
||||||
} catch (java.io.IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("PerformanceLogger::updateXML IO Error:" + e.toString());
|
printMessage("PerformanceLogger::updateXML IO Error: {0}", e); //$NON-NLS-1$
|
||||||
|
} catch (ParserConfigurationException e) {
|
||||||
|
printMessage("PerformanceLogger::updateXML Parser Configuration Error: {0}", e); //$NON-NLS-1$
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
System.out.println("PerformanceLogger::updateXML DOM Error:" + e.toString());
|
printMessage("PerformanceLogger::updateXML DOM Error: {0}", e); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,7 +460,7 @@ public class PerformanceLogger {
|
||||||
private static void updateXMLFileAtStop(ComponentData cd, StartData td) {
|
private static void updateXMLFileAtStop(ComponentData cd, StartData td) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(cd.XMLFile), "UTF8"));
|
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(cd.XMLFile), "UTF8")); //$NON-NLS-1$
|
||||||
cd.doc.getDocumentElement();
|
cd.doc.getDocumentElement();
|
||||||
Element task = td.node;
|
Element task = td.node;
|
||||||
|
|
||||||
|
@ -481,7 +469,7 @@ public class PerformanceLogger {
|
||||||
Long sms = new Long(td.startTime);
|
Long sms = new Long(td.startTime);
|
||||||
Long tms = new Long(td.stopTime);
|
Long tms = new Long(td.stopTime);
|
||||||
/*Calculate the normalization factor*/
|
/*Calculate the normalization factor*/
|
||||||
String normalizedFactor = "invalid";
|
String normalizedFactor = "invalid"; //$NON-NLS-1$
|
||||||
if (samplingTime > 0) {
|
if (samplingTime > 0) {
|
||||||
Long sam = new Long(samplingTime);
|
Long sam = new Long(samplingTime);
|
||||||
Double val = new Double(ems.doubleValue() / sam.doubleValue());
|
Double val = new Double(ems.doubleValue() / sam.doubleValue());
|
||||||
|
@ -489,20 +477,20 @@ public class PerformanceLogger {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the document */
|
/* Update the document */
|
||||||
task.setAttribute("ElapsedTime", ems.toString());
|
task.setAttribute("ElapsedTime", ems.toString()); //$NON-NLS-1$
|
||||||
task.setAttribute("NormalizedFactor", normalizedFactor);
|
task.setAttribute("NormalizedFactor", normalizedFactor); //$NON-NLS-1$
|
||||||
task.setAttribute("StartTime", sms.toString());
|
task.setAttribute("StartTime", sms.toString()); //$NON-NLS-1$
|
||||||
task.setAttribute("StopTime", tms.toString());
|
task.setAttribute("StopTime", tms.toString()); //$NON-NLS-1$
|
||||||
task.setAttribute("StartAt", td.startMethod);
|
task.setAttribute("StartAt", td.startMethod); //$NON-NLS-1$
|
||||||
task.setAttribute("StartThread", td.startThread);
|
task.setAttribute("StartThread", td.startThread); //$NON-NLS-1$
|
||||||
task.setAttribute("StopAt", td.stopMethod);
|
task.setAttribute("StopAt", td.stopMethod); //$NON-NLS-1$
|
||||||
task.setAttribute("StopThread", td.stopThread);
|
task.setAttribute("StopThread", td.stopThread); //$NON-NLS-1$
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Source source = new DOMSource(cd.doc);
|
Source source = new DOMSource(cd.doc);
|
||||||
Result result = new StreamResult(writer);
|
Result result = new StreamResult(writer);
|
||||||
Transformer t = TransformerFactory.newInstance().newTransformer();
|
Transformer t = TransformerFactory.newInstance().newTransformer();
|
||||||
t.setOutputProperty(OutputKeys.INDENT, "yes");
|
t.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
|
||||||
t.transform(source, result);
|
t.transform(source, result);
|
||||||
} catch (TransformerConfigurationException e2) {
|
} catch (TransformerConfigurationException e2) {
|
||||||
} catch (TransformerFactoryConfigurationError e2) {
|
} catch (TransformerFactoryConfigurationError e2) {
|
||||||
|
@ -519,9 +507,9 @@ public class PerformanceLogger {
|
||||||
// serializer.serialize(cd.doc);
|
// serializer.serialize(cd.doc);
|
||||||
// writer.close();
|
// writer.close();
|
||||||
} catch (java.io.IOException e) {
|
} catch (java.io.IOException e) {
|
||||||
System.out.println("PerformanceLogger::updateXMLFileAtStop IO Error:" + e.toString());
|
printMessage("PerformanceLogger::updateXMLFileAtStop IO Error: {0}", e); //$NON-NLS-1$
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
System.out.println("PerformanceLogger::updateXMLFileAtStop DOM Error:" + e.toString());
|
printMessage("PerformanceLogger::updateXMLFileAtStop DOM Error: {0}", e); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -539,7 +527,7 @@ public class PerformanceLogger {
|
||||||
public static String getCurrentProductInfo(int req, String comp_id) {
|
public static String getCurrentProductInfo(int req, String comp_id) {
|
||||||
ComponentData cd = (ComponentData) perfLogRegistry.get(comp_id);
|
ComponentData cd = (ComponentData) perfLogRegistry.get(comp_id);
|
||||||
if (cd == null) {
|
if (cd == null) {
|
||||||
System.out.println("PerformanceLogger::getCurrentProductInfo invalid comp_id");
|
printMessage("PerformanceLogger::getCurrentProductInfo invalid comp_id"); //$NON-NLS-1$
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,10 +561,10 @@ public class PerformanceLogger {
|
||||||
StringWriter strwriter = new StringWriter(100);
|
StringWriter strwriter = new StringWriter(100);
|
||||||
e.printStackTrace(new java.io.PrintWriter(strwriter));
|
e.printStackTrace(new java.io.PrintWriter(strwriter));
|
||||||
String stack = strwriter.toString();
|
String stack = strwriter.toString();
|
||||||
java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(stack, "\r\n");
|
StringTokenizer tokenizer = new StringTokenizer(stack, "\r\n"); //$NON-NLS-1$
|
||||||
/*
|
/*
|
||||||
* Here to parse the exception string to get the caller which is the current method location
|
* Here to parse the exception string to get the caller which is the current method location
|
||||||
* to be obtained. The Exception stack should show the PerformanceLogger start() in the satck first:
|
* to be obtained. The Exception stack should show the PerformanceLogger start() in the stack first:
|
||||||
* -java.lang.Exception
|
* -java.lang.Exception
|
||||||
* -at org.eclipse.rse.logging.performance.PerformanceLogger.start(PerformanceLogger.java:151)
|
* -at org.eclipse.rse.logging.performance.PerformanceLogger.start(PerformanceLogger.java:151)
|
||||||
* -at org.eclipse.rse.logging.performance.PerformanceLogger.start(PerformanceLogger.java:135)
|
* -at org.eclipse.rse.logging.performance.PerformanceLogger.start(PerformanceLogger.java:135)
|
||||||
|
@ -585,24 +573,25 @@ public class PerformanceLogger {
|
||||||
|
|
||||||
for (int i = 0; tokenizer.hasMoreTokens(); i++) {
|
for (int i = 0; tokenizer.hasMoreTokens(); i++) {
|
||||||
methodPath = tokenizer.nextToken();
|
methodPath = tokenizer.nextToken();
|
||||||
if ((methodPath.indexOf("java.lang.Throwable") == -1) && (methodPath.indexOf("logging.performance.PerformanceLogger") == -1)) break;
|
if ((methodPath.indexOf("java.lang.Throwable") == -1) && (methodPath.indexOf("logging.performance.PerformanceLogger") == -1)) break; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
methodPath = methodPath.substring(4);
|
if (methodPath != null) {
|
||||||
if (parsed) {
|
methodPath = methodPath.substring(4);
|
||||||
try {
|
if (parsed) {
|
||||||
|
try {
|
||||||
int i = methodPath.indexOf('(');
|
int i = methodPath.indexOf('(');
|
||||||
if (i != -1) methodPath = methodPath.substring(0, i); //strip of the substring enclosed in ()
|
if (i != -1) methodPath = methodPath.substring(0, i); //strip of the substring enclosed in ()
|
||||||
//Now we have "org.eclipse.rse.logging.performance.PerformanceLogger.start"
|
//Now we have "org.eclipse.rse.logging.performance.PerformanceLogger.start"
|
||||||
i = methodPath.lastIndexOf('.'); //Get the method name after the last period (.)
|
i = methodPath.lastIndexOf('.'); //Get the method name after the last period (.)
|
||||||
String methodName = methodPath.substring(i + 1); //Now we have the method name "start"
|
String methodName = methodPath.substring(i + 1); //Now we have the method name "start"
|
||||||
String className = methodPath.substring(0, i); //remove method name from the string
|
String className = methodPath.substring(0, i); //remove method name from the string
|
||||||
//We are left with "org.eclipse.rse.logging.performance.PerformanceLogger"
|
//We are left with "org.eclipse.rse.logging.performance.PerformanceLogger"
|
||||||
i = className.lastIndexOf('.');
|
i = className.lastIndexOf('.');
|
||||||
if (i != -1) className = className.substring(i + 1); //Now we have the class name "PerformanceLogger"
|
if (i != -1) className = className.substring(i + 1); //Now we have the class name "PerformanceLogger"
|
||||||
methodPath = className + "." + methodName;
|
methodPath = className + "." + methodName; //$NON-NLS-1$
|
||||||
} catch (IndexOutOfBoundsException ex) {
|
} catch (IndexOutOfBoundsException ex) {
|
||||||
System.out.println("PerformanceLogger:getMethodName exception" + ex.toString());
|
printMessage("PerformanceLogger:getMethodName exception {0}", ex); //$NON-NLS-1$
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return methodPath; /*delete " at" in the beginning of the string */
|
return methodPath; /*delete " at" in the beginning of the string */
|
||||||
|
@ -622,11 +611,11 @@ public class PerformanceLogger {
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
public static void listSystemProfile() {
|
public static void listSystemProfile() {
|
||||||
System.out.println("java version : " + System.getProperty("java.version"));
|
System.out.println("java version : " + System.getProperty("java.version")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
System.out.println("OS name : " + System.getProperty("os.name"));
|
System.out.println("OS name : " + System.getProperty("os.name")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
System.out.println("OS version : " + System.getProperty("os.version"));
|
System.out.println("OS version : " + System.getProperty("os.version")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
System.out.println("working dir : " + System.getProperty("user.dir"));
|
System.out.println("working dir : " + System.getProperty("user.dir")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
System.out.println("home dir : " + System.getProperty("home.dir"));
|
System.out.println("home dir : " + System.getProperty("home.dir")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -648,44 +637,44 @@ public class PerformanceLogger {
|
||||||
}
|
}
|
||||||
|
|
||||||
PerformanceLogger.enablePerformanceLogging(true);
|
PerformanceLogger.enablePerformanceLogging(true);
|
||||||
String key = PerformanceLogger.register("", "WDSC", "5120");
|
String key = PerformanceLogger.register("", "WDSC", "5120"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
key = PerformanceLogger.register("RSE", "WDSC", "5120");
|
key = PerformanceLogger.register("RSE", "WDSC", "5120"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
PerformanceLogger.deRegister("XXX"); //not registered key previously
|
PerformanceLogger.deRegister("XXX"); //not registered key previously //$NON-NLS-1$
|
||||||
System.out.println("Product info : " + PerformanceLogger.getCurrentProductInfo(PerformanceLogger.OPTION_GET_FEATURE, key) + " "
|
System.out.println("Product info : " + PerformanceLogger.getCurrentProductInfo(PerformanceLogger.OPTION_GET_FEATURE, key) + " " //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ PerformanceLogger.getCurrentProductInfo(PerformanceLogger.OPTION_GET_VERSION, key));
|
+ PerformanceLogger.getCurrentProductInfo(PerformanceLogger.OPTION_GET_VERSION, key));
|
||||||
PerformanceLogger.start(key, "NOT_NESTED_1");
|
PerformanceLogger.start(key, "NOT_NESTED_1"); //$NON-NLS-1$
|
||||||
for (i = 0; i < 1000000; i++) {
|
for (i = 0; i < 1000000; i++) {
|
||||||
//empty performance test loop
|
//empty performance test loop
|
||||||
}
|
}
|
||||||
PerformanceLogger.stop(key);
|
PerformanceLogger.stop(key);
|
||||||
|
|
||||||
PerformanceLogger.start(key, "NESTED_ONE");
|
PerformanceLogger.start(key, "NESTED_ONE"); //$NON-NLS-1$
|
||||||
for (i = 0; i < 500; i++) {
|
for (i = 0; i < 500; i++) {
|
||||||
//empty performance test loop
|
//empty performance test loop
|
||||||
}
|
}
|
||||||
PerformanceLogger.start(key, "NESTED_ONE_CHILD");
|
PerformanceLogger.start(key, "NESTED_ONE_CHILD"); //$NON-NLS-1$
|
||||||
for (i = 0; i < 300; i++) {
|
for (i = 0; i < 300; i++) {
|
||||||
//empty performance test loop
|
//empty performance test loop
|
||||||
}
|
}
|
||||||
PerformanceLogger.stop(key);
|
PerformanceLogger.stop(key);
|
||||||
PerformanceLogger.stop(key);
|
PerformanceLogger.stop(key);
|
||||||
|
|
||||||
PerformanceLogger.start(key, "NOT_NESTED_2");
|
PerformanceLogger.start(key, "NOT_NESTED_2"); //$NON-NLS-1$
|
||||||
for (i = 0; i < 2000000; i++) {
|
for (i = 0; i < 2000000; i++) {
|
||||||
//empty performance test loop
|
//empty performance test loop
|
||||||
}
|
}
|
||||||
PerformanceLogger.stop(key);
|
PerformanceLogger.stop(key);
|
||||||
|
|
||||||
PerformanceLogger.start(key, "NESTED_THREE");
|
PerformanceLogger.start(key, "NESTED_THREE"); //$NON-NLS-1$
|
||||||
for (i = 0; i < 300; i++) {
|
for (i = 0; i < 300; i++) {
|
||||||
//empty performance test loop
|
//empty performance test loop
|
||||||
}
|
}
|
||||||
PerformanceLogger.start(key, "NESTED_TWO_CHILD1");
|
PerformanceLogger.start(key, "NESTED_TWO_CHILD1"); //$NON-NLS-1$
|
||||||
PerformanceLogger.start(key, "NESTED_TWO_CHILD2");
|
PerformanceLogger.start(key, "NESTED_TWO_CHILD2"); //$NON-NLS-1$
|
||||||
for (i = 0; i < 4000; i++) {
|
for (i = 0; i < 4000; i++) {
|
||||||
//empty performance test loop
|
//empty performance test loop
|
||||||
}
|
}
|
||||||
PerformanceLogger.start(key, "NESTED_TWO_CHILD3");
|
PerformanceLogger.start(key, "NESTED_TWO_CHILD3"); //$NON-NLS-1$
|
||||||
for (i = 0; i < 6000; i++) {
|
for (i = 0; i < 6000; i++) {
|
||||||
//empty performance test loop
|
//empty performance test loop
|
||||||
}
|
}
|
||||||
|
@ -694,7 +683,7 @@ public class PerformanceLogger {
|
||||||
PerformanceLogger.stop(key);
|
PerformanceLogger.stop(key);
|
||||||
PerformanceLogger.stop(key);
|
PerformanceLogger.stop(key);
|
||||||
|
|
||||||
PerformanceLogger.start("ABC"); //Expect error: not registered
|
PerformanceLogger.start("ABC"); //Expect error: not registered //$NON-NLS-1$
|
||||||
PerformanceLogger.start(key); //record timer in the previous registered component
|
PerformanceLogger.start(key); //record timer in the previous registered component
|
||||||
for (i = 0; i < 3000000; i++) {
|
for (i = 0; i < 3000000; i++) {
|
||||||
//empty performance test loop
|
//empty performance test loop
|
||||||
|
|
|
@ -25,8 +25,8 @@ import java.util.Set;
|
||||||
*/
|
*/
|
||||||
public class LabelUtil {
|
public class LabelUtil {
|
||||||
|
|
||||||
private final static String upperLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
private final static String upperLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //$NON-NLS-1$
|
||||||
private final static String lowerLetters = "abcdefghijklmnopqrstuvwxyz";
|
private final static String lowerLetters = "abcdefghijklmnopqrstuvwxyz"; //$NON-NLS-1$
|
||||||
private final static char lpar = '(';
|
private final static char lpar = '(';
|
||||||
private final static char rpar = ')';
|
private final static char rpar = ')';
|
||||||
private final static char trigger = '&';
|
private final static char trigger = '&';
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
package org.eclipse.rse.logging.ui;
|
package org.eclipse.rse.logging.ui;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.Plugin;
|
import org.eclipse.core.runtime.Plugin;
|
||||||
|
@ -33,7 +32,6 @@ import org.eclipse.swt.widgets.Button;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Control;
|
import org.eclipse.swt.widgets.Control;
|
||||||
import org.eclipse.swt.widgets.Group;
|
import org.eclipse.swt.widgets.Group;
|
||||||
import org.eclipse.swt.widgets.Label;
|
|
||||||
import org.eclipse.ui.IWorkbench;
|
import org.eclipse.ui.IWorkbench;
|
||||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
@ -116,15 +114,15 @@ public abstract class LoggingPreferencePage extends PreferencePage implements IW
|
||||||
* @param text the text for the new label
|
* @param text the text for the new label
|
||||||
* @return the new label
|
* @return the new label
|
||||||
*/
|
*/
|
||||||
private Label createLabel(Composite parent, int span, String text) {
|
// private Label createLabel(Composite parent, int span, String text) {
|
||||||
Label label = new Label(parent, SWT.LEFT);
|
// Label label = new Label(parent, SWT.LEFT);
|
||||||
label.setText(text);
|
// label.setText(text);
|
||||||
GridData data = new GridData();
|
// GridData data = new GridData();
|
||||||
data.horizontalSpan = span;
|
// data.horizontalSpan = span;
|
||||||
data.horizontalAlignment = GridData.FILL;
|
// data.horizontalAlignment = GridData.FILL;
|
||||||
label.setLayoutData(data);
|
// label.setLayoutData(data);
|
||||||
return label;
|
// return label;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method declared on PreferencePage
|
* Method declared on PreferencePage
|
||||||
|
@ -137,7 +135,7 @@ public abstract class LoggingPreferencePage extends PreferencePage implements IW
|
||||||
// createLabel(composite_tab, 1, topLabel1);
|
// createLabel(composite_tab, 1, topLabel1);
|
||||||
String topLabel2 = LoggingPreferenceLabels.LOGGING_PREFERENCE_PAGE_TOPLABEL2;
|
String topLabel2 = LoggingPreferenceLabels.LOGGING_PREFERENCE_PAGE_TOPLABEL2;
|
||||||
Group group1 = createGroup(composite_tab, 1, 1, topLabel2);
|
Group group1 = createGroup(composite_tab, 1, 1, topLabel2);
|
||||||
Set used = LabelUtil.usedFromString("ad"); // the mnemonics already used on preference page (in English)
|
Set used = LabelUtil.usedFromString("ad"); //$NON-NLS-1$ // the mnemonics already used on preference page (in English)
|
||||||
String text = LoggingPreferenceLabels.LOGGING_PREFERENCE_PAGE_ERRORS_ONLY;
|
String text = LoggingPreferenceLabels.LOGGING_PREFERENCE_PAGE_ERRORS_ONLY;
|
||||||
radioButton0 = createRadioButton(group1, LabelUtil.assignMnemonic(text, used));
|
radioButton0 = createRadioButton(group1, LabelUtil.assignMnemonic(text, used));
|
||||||
text = LoggingPreferenceLabels.LOGGING_PREFERENCE_PAGE_WARNINGS_ERRORS;
|
text = LoggingPreferenceLabels.LOGGING_PREFERENCE_PAGE_WARNINGS_ERRORS;
|
||||||
|
@ -149,7 +147,7 @@ public abstract class LoggingPreferencePage extends PreferencePage implements IW
|
||||||
radioButton3 = createRadioButton(group1, LabelUtil.assignMnemonic(text, used));
|
radioButton3 = createRadioButton(group1, LabelUtil.assignMnemonic(text, used));
|
||||||
}
|
}
|
||||||
initializeValues();
|
initializeValues();
|
||||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, "org.eclipse.rse.logging.rsel0000");
|
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, "org.eclipse.rse.logging.rsel0000"); //$NON-NLS-1$
|
||||||
return composite_tab;
|
return composite_tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue