FileDocCategorySizeDatePackage
PerformanceMonitor.javaAPI DocJ2ME MIDP 2.05960Thu Nov 07 12:02:24 GMT 2002com.sun.midp.perfmon

PerformanceMonitor

public interface PerformanceMonitor
A class that implements the PerformanceMonitor interface. A performance monitor session consists of a start time [ call start method ] and an end time [ call end method ]. This class tracks a number of system resources and provides the ability to track system resource for delta's (between the start and end of a session).

Each performance monitor session must include a call to first the start and second the end methods in order to measure system resource delta's. Once a proper session call sequence has been made the application can then access the appropriate methods to retrieve the desired system resource delta. Once a call has been made to start method a new session has been started. If the application calls end before start an error will be returned.

In order to ensure data integrity the implemenation of the PerformanceMonitor interface requires the application using the interface always uses the interface with the proper calling sequence. Below is an example of how an application would use the PerformanceMonitor interface (and/or implemenation) correctly:

This example of code shows how an application might want to use the PerformanceMonitor interface to measure read() I/O resources.

start = perfmon.start("read()"); // start a perfmon session

for (int i = 0 ; i < len ; i++ ) {
if ((ch = input.read()) != -1){
if (ch <= ' ') ch = ' ';
b.append((char) ch);
}
}
end = perfmon.end(); // end a perfmon session

perfmon.report(System.err); // print stdout standard report format

perfmon.write(System.err); // write key/value pair http-to-servlet

Fields Summary
static final int
INSTRUCTION_COUNTER
Specifies instruction counter.
static final int
THREAD_SWITCH_COUNTER
Specifies thread switch counter.
static final int
DYNAMIC_OBJECT_COUNTER
Specifies dynamic object counter.
static final int
DYNAMIC_ALLOC_COUNTER
Specifies dynamic allocation counter.
static final int
DYNAMIC_DEALLOC_COUNTER
Specifies dynamic deallocation counter.
static final int
GARBAGE_COLLECTION_COUNTER
Specifies garbage collection counter.
static final int
TOTAL_GC_DEFERRALS
Specifies total garbage collection deferrals.
static final int
MAX_GC_DEFERRALS
Specifies maximum garbage collection deferrals.
static final int
GARBAGE_COLLECTION_RESCANS
Specifies garbage collection rescans.
static final int
TOTAL_SYSTEM_PERFMON_COUNTERS
Total number of performance measurement counters.
Constructors Summary
Methods Summary
public longend()
Ends the performance monitor timer and system measurements and sets (or resets) the end time in milliseconds.

return
end time in milliseconds (long - returns Date.getTime())

public intgetDelta(int perfmon_id)
Gets the appropriate perfmon status delta measurement value between a specific start and end time.

param
perfmon_id performon id (e.g. THREAD_SWITCH_COUNTER).
return
perfmon stat (int) value (between start and end)
exception
IllegalStateException if start or end equal 0
exception
IllegalArgumentException invalid measurement type

public longgetElapsedTime()
Gets the current perfmon session end time in milliseconds.

return
current perfmon end time in milliseconds
exception
IllegalStateException if start or end equal 0

public longgetEndTime()
Gets the current perfmon session end time in milliseconds.

return
current perfmon end time in milliseconds

public longgetStartTime()
Gets the current perfmon session start time in milliseconds.

return
current perfmon start time in milliseconds

public intgetStat(int perfmon_id)
Gets the current perfmon stat value.

param
perfmon_id perfmon id (e.g. THREAD_SWITCH_COUNTER).
return
perfmon status current (int) value
exception
IllegalArgumentException an invalid perfmon id type

public voidreport(java.io.PrintStream printstream)
Reports a standard output format to the PrintStream specified which includes delta measurements (e.g. elapsed time) between a specific start and end time.

param
printstream where to write the output buffer

public longstart(java.lang.String testname)
Starts the performance monitor timer and system measurements and sets (or resets) the start time in milliseconds.

param
testname current test name
return
start time in milliseconds (long - returns Date.getTime())