The pulse logger is designed in such a way as to gather all of the pulse statistics
together even though half of the pulse occurs on the FX thread and half on the
render thread, and therefore two sets of pulse data are being accumulated
concurrently. The pulseStart, pulseEnd, renderStart,
and renderEnd methods must be called appropriately by the runtime
to ensure that the logging system works correctly.
| Modifier and Type | Class and Description |
|---|---|
| private static class | PrintLogger.
A mutable integer to be used in the counter map |
| private class | PrintLogger.
The data we collect per pulse. |
| pack-priv class |
| Modifier and Type | Field and Description |
|---|---|
| private AtomicInteger | active
A synchronization object for printing arbitrage. |
| private static final int | AVAILABLE
PulseData object states |
| private static final int | |
| private static final int | EXIT_ON_PULSE
Optionally exit after a given number of pulses |
| private volatile PrintLogger. | fxData
References to PulseData for the FX thread (fxData) and the Render thread (renderData). |
| private Thread | |
| private PrintLogger. | head
The queue of all PulseData objects, both available and those in use. |
| private static final int | |
| private static final int | |
| private long | lastPulseStartTime
Keeps track of the start of the previous pulse, such that we can print out the time interval between the start of pulses. |
| private final ThreadLocal | |
| private int | pulseCount
We have a simple counter that keeps track of the current pulse number. |
| private volatile PrintLogger. | renderData
References to PulseData for the FX thread (fxData) and the Render thread (renderData). |
| private PrintLogger. | |
| private static long | THRESHOLD
A time in milliseconds which defines the threshold. |
| private volatile int | wrapCount
When printing the truncated form of the pulse, we just print one truncated form after another, such as: [5][2][4] This way we don't cause the console to scroll far vertically in the case of fast pulses. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | addMessage(String
The message to log. A newline will be added automatically. message)Overrides com. Adds a message to the log for the pulse. |
| private PrintLogger. | |
| public static Logger | |
| public void | incrementCounter(String
The name for the counter. counter)Overrides com. Increments the given named per-pulse counter. |
| public void | |
| public void | |
| public void | pulseStart()
Overrides com. MUST be called at the start of every pulse. |
| public void | renderEnd()
Overrides com. Must be called at the end of rendering, if a previous
call to |
| public void | renderStart()
Overrides com. Must be called before any set of render jobs for a given pulse begin. |
| active | back to summary |
|---|---|
| private AtomicInteger active A synchronization object for printing arbitrage. | |
| AVAILABLE | back to summary |
|---|---|
| private static final int AVAILABLE PulseData object states | |
| COMPLETE | back to summary |
|---|---|
| private static final int COMPLETE | |
| EXIT_ON_PULSE | back to summary |
|---|---|
| private static final int EXIT_ON_PULSE Optionally exit after a given number of pulses | |
| fxData | back to summary |
|---|---|
| private volatile PrintLogger. References to PulseData for the FX thread (fxData) and the Render thread (renderData). | |
| fxThread | back to summary |
|---|---|
| private Thread fxThread | |
| head | back to summary |
|---|---|
| private PrintLogger. The queue of all PulseData objects, both available and those in use. New PulseData objects are allocated from head if the state is AVAILABLE. They are re-linked at tail with the state INCOMPLETE. Once fully processed they will change their state back to AVAILABLE and will become ready for reuse. | |
| INCOMPLETE | back to summary |
|---|---|
| private static final int INCOMPLETE | |
| INTER_PULSE_DATA | back to summary |
|---|---|
| private static final int INTER_PULSE_DATA | |
| lastPulseStartTime | back to summary |
|---|---|
| private long lastPulseStartTime Keeps track of the start of the previous pulse, such that we can print out the time interval between the start of pulses. | |
| phaseData | back to summary |
|---|---|
| private final ThreadLocal<PrintLogger. | |
| pulseCount | back to summary |
|---|---|
| private int pulseCount We have a simple counter that keeps track of the current pulse number. INTER_PULSE_DATA is used to mark data that comes between pulses. | |
| renderData | back to summary |
|---|---|
| private volatile PrintLogger. References to PulseData for the FX thread (fxData) and the Render thread (renderData). | |
| tail | back to summary |
|---|---|
| private PrintLogger. | |
| THRESHOLD | back to summary |
|---|---|
| private static long THRESHOLD A time in milliseconds which defines the threshold. If a pulse lasts longer than the threshold, then it is logged, otherwise an abbreviated representation including only the time of the pulse is logged. | |
| wrapCount | back to summary |
|---|---|
| private volatile int wrapCount When printing the truncated form of the pulse, we just print one truncated form after another, such as: [5][2][4] This way we don't cause the console to scroll far vertically in the case of fast pulses. We do this so that relevant information (pulses that exceed the threshold) is easy to find and remains visible as long as possible in the console. However, we don't want to scroll too far off to the right either, so we keep track of how many "quick pulses" have happened in a row. When we've exceeded some fixed number (20, say) then we will insert a newline into the log. | |
| PrintLogger | back to summary |
|---|---|
| private PrintLogger() Disallow instantiation. | |
| addMessage | back to summary |
|---|---|
| public void addMessage(String message) Overrides com. Adds a message to the log for the pulse. | |
| allocate | back to summary |
|---|---|
| private PrintLogger. Allocate and initialize a PulseData object | |
| createInstance | back to summary |
|---|---|
| public static Logger createInstance() | |
| incrementCounter | back to summary |
|---|---|
| public void incrementCounter(String counter) Overrides com. Increments the given named per-pulse counter. | |
| newPhase | back to summary |
|---|---|
| public void newPhase(String name) Overrides com.
| |
| pulseEnd | back to summary |
|---|---|
| public void pulseEnd() Overrides com. Must be called at the end of the pulse. If there was no rendering started during this pulse, then this method will cause the pulse data to be logged. Otherwise, the pulse data is logged when rendering is ended. However, as soon as pulseEnd is called, we are ready for another call to pulseStart.
| |
| pulseStart | back to summary |
|---|---|
| public void pulseStart() Overrides com. MUST be called at the start of every pulse. This method will initialize the fxData buffer so that subsequent calls to fxMessage will write to this buffer.
| |
| renderEnd | back to summary |
|---|---|
| public void renderEnd() Overrides com. Must be called at the end of rendering, if a previous
call to
| |
| renderStart | back to summary |
|---|---|
| public void renderStart() Overrides com. Must be called before any set of render jobs for a given pulse begin. This method will initialize the renderData buffer so that subsequent calls to renderMessage will write to this buffer. I have found that sometimes renderMessage is called without a pulse being started. Such cases are exceptional and appear to happen only at startup, and such cases are simply not logged.
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv int |
| Access | Constructor and Description |
|---|---|
| private |
| value | back to summary |
|---|---|
| pack-priv int value | |
| Counter | back to summary |
|---|---|
| private Counter() | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv Map | |
| pack-priv long | |
| pack-priv StringBuffer | |
| pack-priv PrintLogger. | |
| pack-priv int | |
| pack-priv boolean | |
| pack-priv long | |
| pack-priv volatile int |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | |
| pack-priv void |
| counters | back to summary |
|---|---|
| pack-priv Map<String, PrintLogger. | |
| interval | back to summary |
|---|---|
| pack-priv long interval | |
| message | back to summary |
|---|---|
| pack-priv StringBuffer message | |
| next | back to summary |
|---|---|
| pack-priv PrintLogger. | |
| pulseCount | back to summary |
|---|---|
| pack-priv int pulseCount | |
| pushedRender | back to summary |
|---|---|
| pack-priv boolean pushedRender | |
| startTime | back to summary |
|---|---|
| pack-priv long startTime | |
| state | back to summary |
|---|---|
| pack-priv volatile int state | |
| PulseData | back to summary |
|---|---|
| private PulseData() | |
| init | back to summary |
|---|---|
| pack-priv void init(int n) | |
| printAndReset | back to summary |
|---|---|
| pack-priv void printAndReset() | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv String | |
| pack-priv long |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| phaseName | back to summary |
|---|---|
| pack-priv String phaseName | |
| phaseStart | back to summary |
|---|---|
| pack-priv long phaseStart | |
| ThreadLocalData | back to summary |
|---|---|
| pack-priv ThreadLocalData() | |