Save This Page
Home » openjdk-7 » sun » misc » [javadoc | source]
sun.misc
public class: PerformanceLogger [javadoc | source]
java.lang.Object
   sun.misc.PerformanceLogger
This class is intended to be a central place for the jdk to log timing events of interest. There is pre-defined event of startTime, as well as a general mechanism of setting aribtrary times in an array. All unreserved times in the array can be used by callers in application-defined situations. The caller is responsible for setting and getting all times and for doing whatever analysis is interesting; this class is merely a central container for those timing values. Note that, due to the variables in this class being static, use of particular time values by multiple applets will cause confusing results. For example, if plugin runs two applets simultaneously, the initTime for those applets will collide and the results may be undefined.

To automatically track startup performance in an app or applet, use the command-line parameter sun.perflog as follows:
-Dsun.perflog[=file:]
where simply using the parameter with no value will enable output to the console and a value of "file:" will cause that given filename to be created and used for all output.

By default, times are measured using System.currentTimeMillis(). To use System.nanoTime() instead, add the command-line parameter:
-Dsun.perflog.nano=true

Warning: Use at your own risk! This class is intended for internal testing purposes only and may be removed at any time. More permanent monitoring and profiling APIs are expected to be developed for future releases and this class will cease to exist once those APIs are in place.

Nested Class Summary:
static class  PerformanceLogger.TimeData  Internal class used to store time/message data together. 
Method from sun.misc.PerformanceLogger Summary:
getMessageAtIndex,   getStartTime,   getTimeAtIndex,   loggingEnabled,   outputLog,   outputLog,   setBaseTime,   setStartTime,   setStartTime,   setTime,   setTime
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from sun.misc.PerformanceLogger Detail:
 public static String getMessageAtIndex(int index) 
    Returns message at given index.
 public static long getStartTime() 
    Gets the start time, which should be the time when the java process started, prior to the VM actually being loaded.
 public static long getTimeAtIndex(int index) 
    Returns time at given index.
 public static boolean loggingEnabled() 
    Returns status of whether logging is enabled or not. This is provided as a convenience method so that users do not have to perform the same GetPropertyAction check as above to determine whether to enable performance logging.
 public static  void outputLog() 
    Outputs all data to whatever location the user specified via sun.perflog command-line parameter.
 public static  void outputLog(Writer writer) 
    Outputs all data to parameter-specified Writer object
 public static  void setBaseTime(long time) 
    Sets the base time, output can then be displayed as offsets from the base time;.
 public static  void setStartTime(String message) 
    Sets the start time. Ideally, this is the earliest time available during the startup of a Java applet or application. This time is later used to analyze the difference between the initial startup time and other events in the system (such as an applet's init time).
 public static  void setStartTime(String message,
    long time) 
    Sets the start time. This version of the method is given the time to log, instead of expecting this method to get the time itself. This is done in case the time was recorded much earlier than this method was called.
 public static int setTime(String message) 
    Sets the value of a given time and returns the index of the slot that that time was stored in.
 public static int setTime(String message,
    long time) 
    Sets the value of a given time and returns the index of the slot that that time was stored in. This version of the method is given the time to log, instead of expecting this method to get the time itself. This is done in case the time was recorded much earlier than this method was called.