|
" 2013 FRC Java API " |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.squawk.VM.Stats
public static class VM.Stats
Virtual machine statistics.
Note that these statistics are simple counters that may wrap to negative values. Negative values can simply be treated as unsigned values.
The expeceted usage of these counters is to be polled periodically, so the absolute value is not as important as the difference between different readings. You will need to be prepared to handle a counter wrapping during two readings, but if samples are frequent, you shouldn't have to worry about the counters wrapping more than once.
EXAMPLE 1 (Perf meter): totalTimeDiff = totalTime[n] - totalTime[n-1]; gcTimeDiff = gcTime[n] - gcTime[n-1]; sysTimeDiff = sysTime[n] - sysTime[n-1]; userTimeDiff = totalTime[n] - (gcTime[n] + sysTime[n]); System.out.println("User time: " + (userTimeDiff * 100) / totalTimeDiff + "%"); System.out.println("GC time: " + (gcTimeDiff * 100) / totalTimeDiff + "%"); System.out.println("System/Idle time: " + (sysTimeDiff * 100) / totalTimeDiff + "%");
Field Summary | |
---|---|
static int |
NUM_STAT_VALUES
|
static int |
STAT_BRANCH_COUNT
|
static int |
STAT_BYTES_LAST_FREED
|
static int |
STAT_BYTES_TOTAL_ALLOCATED
|
static int |
STAT_BYTES_TOTAL_FREED
|
static int |
STAT_CONTENDED_MONITOR_COUNT
|
static int |
STAT_FIRST_COUNT_STAT
|
static int |
STAT_FULL_GC_COUNT
|
static int |
STAT_FULL_GC_TIME
|
static int |
STAT_GC_TIME
|
static int |
STAT_HEAP_FREE
|
static int |
STAT_HEAP_TOTAL
|
static int |
STAT_LAST_GC_TIME
|
static int |
STAT_MAX_FULLGC_TIME
|
static int |
STAT_MAX_PARTGC_TIME
|
static int |
STAT_MAX_STACK_SIZE
|
static int |
STAT_MONITORS_ALLOCATED
|
static int |
STAT_OBJECTS_TOTAL_ALLOCATED
|
static int |
STAT_PARTIAL_GC_COUNT
|
static int |
STAT_PARTIAL_GC_TIME
|
static int |
STAT_STACKS_ALLOCATED
|
static int |
STAT_THREAD_SWITCH_COUNT
|
static int |
STAT_THREADS_ALLOCATED
|
static int |
STAT_THROW_COUNT
|
static int |
STAT_WAIT_TIME
|
static int |
STAT_WALL_TIME
tag for data sent by sendStatData() |
Constructor Summary | |
---|---|
VM.Stats()
Create a new Stats object, This is primarily used when calling sendStatData(java.io.DataOutputStream) . |
Method Summary | |
---|---|
static int |
getContendedMontorEnterCount()
Return the number of times that a thread was blocked trying to synchronize on an object. |
static int |
getMaxStackSize()
Return size of the largest stack ever allocated. |
static int |
getMonitorsAllocatedCount()
Return the number of monitors allocated. |
static int |
getObjectsAllocatedTotal()
Get the number of objects allocated since reboot. |
static int |
getStacksAllocatedCount()
Return the number of stacks allocated. |
static int |
getThreadsAllocatedCount()
Get the number of Thread objects allocated since reboot. |
static int |
getThreadSwitchCount()
Return count of thread context switching since reboot. |
static int |
getThrowCount()
Return number of exceptions thrown. |
static long |
getTotalWaitTime()
Get the total time the VM was idle. |
static void |
initHeapStats()
Pre-create all data structures used in heap stats, so heap walking won't allocate more memory. |
static void |
printHeapStats(Object startObj,
boolean printInstances)
Do heap walk from start object (or whole heap is startObj is null). |
static void |
readAllValues(long[] values)
Take a sample of all data and store into values . |
void |
sendStatData(DataOutputStream dos)
Take a sample of all statics and send to output stream dos . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int STAT_WALL_TIME
public static final int STAT_WAIT_TIME
public static final int STAT_GC_TIME
public static final int STAT_FULL_GC_TIME
public static final int STAT_PARTIAL_GC_TIME
public static final int STAT_LAST_GC_TIME
public static final int STAT_MAX_FULLGC_TIME
public static final int STAT_MAX_PARTGC_TIME
public static final int STAT_FIRST_COUNT_STAT
public static final int STAT_FULL_GC_COUNT
public static final int STAT_PARTIAL_GC_COUNT
public static final int STAT_BYTES_LAST_FREED
public static final int STAT_BYTES_TOTAL_FREED
public static final int STAT_BYTES_TOTAL_ALLOCATED
public static final int STAT_OBJECTS_TOTAL_ALLOCATED
public static final int STAT_THREADS_ALLOCATED
public static final int STAT_THREAD_SWITCH_COUNT
public static final int STAT_CONTENDED_MONITOR_COUNT
public static final int STAT_MONITORS_ALLOCATED
public static final int STAT_STACKS_ALLOCATED
public static final int STAT_MAX_STACK_SIZE
public static final int STAT_THROW_COUNT
public static final int STAT_BRANCH_COUNT
public static final int STAT_HEAP_FREE
public static final int STAT_HEAP_TOTAL
public static final int NUM_STAT_VALUES
Constructor Detail |
---|
public VM.Stats()
sendStatData(java.io.DataOutputStream)
.
Method Detail |
---|
public static long getTotalWaitTime()
This typically means waiting for timeouts or IO.
public static int getObjectsAllocatedTotal()
public static int getThreadsAllocatedCount()
public static int getThreadSwitchCount()
This does not include system-level switches that occur for GC, exception throwing, etc.
public static int getContendedMontorEnterCount()
Note that this counts the initial contention. A thread may be released to aquire the lock, but another thread (potentially higher priority) runs first, and actually acquires the lock. The first thread will then have to wait again.
public static int getMonitorsAllocatedCount()
Often, uncontended locking is handled by the interpreter in the pendingMonitors cache. But if the cache is full, or there is contention, or Object.wait() is used, or a threadd is switched out while holding a virtual monitor, then a real monitor has to be allocated for an object. It is possible for the monitor for an object to come and go, so there is the possibility of "monitor object thrashing".
public static int getStacksAllocatedCount()
Stacks are allocated for each thread, and as more frames are needed, new stacks are created to replace the original stacks (typically at 2x the size of the original stack). The default stack size is about 160 words.
public static int getMaxStackSize()
public static int getThrowCount()
public static void initHeapStats()
public static void printHeapStats(Object startObj, boolean printInstances)
startObj
- the object to start walking from , or nullprintInstances
- public static void readAllValues(long[] values)
values
.This is simply a convenience method.
values
- must have length of at least NUM_STAT_VALUES
.public void sendStatData(DataOutputStream dos)
dos
. The format of the data is:
byte tag = 0 long value byte tag = 1 long value ... byte tag = NUM_STAT_VALUES - 1 long valueThe data can be read by a DataInputStream.
dos
- output stream to send values.
|
" 2013 FRC Java API " |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |