com.sap.ip.me.api.services
Class PerformanceLog

java.lang.Object
  extended bycom.sap.ip.me.api.services.PerformanceLog

public abstract class PerformanceLog
extends java.lang.Object

Class for logging running time and memory usage between specified measurement points. The PerformanceLog has to be enabled in MobileEngine.config with Property Key 'MobileEngine.Trace.PerformanceLog.Enabled = true'.
Example for usage:

public void methodToBeMeasured() {
Object perfLogTag = PerformanceLog.methodStarted(this);
try{
//put the code to be measured in here
}
catch(Exception e ){

} finally {
PerformanceLog.methodFinished(perfLogTag, "additional description");
}
}

Important: methodFinished() must be called at the end of any method that shall be traced, even if an Exception has been risen. Therefore, it must be called from a finally clause.

Author:
SAP AG

Constructor Summary
protected PerformanceLog()
           
 
Method Summary
protected static PerformanceLog getInstance()
           
protected  void instanceMethodFinished(java.lang.Object traceTag, java.lang.String text)
           
protected  void instanceMethodFinished(java.lang.String text)
           
protected  void instanceMethodStarted()
           
protected  java.lang.Object instanceMethodStarted(java.lang.Object self)
           
static boolean isOn()
          Returns the state of PerformanceLog.
static void methodFinished(java.lang.Object traceTag, java.lang.String text)
          Logs the time and memory usage between the last call of PerformanceLog.methodStarted() and the call of this method.
static void methodFinished(java.lang.String text)
          Logs the time and memory usage between the last call of PerformanceLog.methodStarted() and the call of this method.
static void methodStarted()
          Method has to be called at start of any method that shall be traced.
static java.lang.Object methodStarted(java.lang.Object self)
          Method has to be called at start of any method that shall be traced.
static void print()
          Deprecated. Only included for compatibility reasons. No external call of this is needed.
static void reset()
          Deprecated. Clears the trace stack. No external call of this is needed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PerformanceLog

protected PerformanceLog()
Method Detail

getInstance

protected static final PerformanceLog getInstance()
Returns:
the instance

isOn

public static final boolean isOn()
Returns the state of PerformanceLog. There is no need to check the state before calling methodStarted().

Returns:
True if PerformanceLog is enabled

reset

public static final void reset()
Deprecated. Clears the trace stack. No external call of this is needed.


print

public static final void print()
Deprecated. Only included for compatibility reasons. No external call of this is needed.


methodStarted

public static final void methodStarted()
Method has to be called at start of any method that shall be traced. Usage of PerformanceLog.methodStarted() requires that PerformanceLog.methodFinished(String text) is called at termination of traced method !


instanceMethodStarted

protected void instanceMethodStarted()

methodStarted

public static final java.lang.Object methodStarted(java.lang.Object self)
Method has to be called at start of any method that shall be traced. Usage of PerformanceLog.methodStarted(Object self) requires that PerformanceLog.methodFinished(Object self, String text) is called at termination of traced method ! This method is used to set another master measurement point. A master groups following measurement points to himself. This results in better overview and error prevention in the Log.

Parameters:
self - Reference on the calling Object. This sets the new Master for the Log.
Returns:
Trace tag

instanceMethodStarted

protected java.lang.Object instanceMethodStarted(java.lang.Object self)

methodFinished

public static void methodFinished(java.lang.String text)
Logs the time and memory usage between the last call of PerformanceLog.methodStarted() and the call of this method. Method must be called at end of any method that shall be traced, even if an Exception has been risen. Therefore, it must be called from a finally clause. Usage of PerformanceLog.methodFinished() requires that PerformanceLog.methodStarted() has been called at start of traced method!

Parameters:
text - Additional description for the measurement point

instanceMethodFinished

protected void instanceMethodFinished(java.lang.String text)

methodFinished

public static void methodFinished(java.lang.Object traceTag,
                                  java.lang.String text)
Logs the time and memory usage between the last call of PerformanceLog.methodStarted() and the call of this method. Method must be called at end of any method that shall be traced, even if an Exception has been risen. Therefore, it must be called from a finally clause. Usage of PerformanceLog.methodFinished(Object traceTag, String text) requires that PerformanceLog.methodStarted(Object self) has been called at start of traced method! This method releases a master measurement point.

Parameters:
traceTag - Tag Object generated with methodStarted(this)
text - Additional description for the measurement point

instanceMethodFinished

protected void instanceMethodFinished(java.lang.Object traceTag,
                                      java.lang.String text)


Copyright © 2003 SAP AG. All Rights Reserved.