public class ThreadData
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private long |
cpuTimeTicks
Stores the number of assigned CPU time ticks.
|
private long |
nesting
Stores the nesting of reentrant calls.
|
private RecorderElement |
recorderElement
Stores the recorder element assigned to this thread (to be used if
no other recording element can be assigned).
|
private RecorderElement[] |
stack
Stores the recording elements retrieved from the stack.
|
private static int |
STACK_INCREMENT
Defines the stack increment in case that there is no more space and also
the initial stack size.
|
private boolean[] |
stackDuplicates
Stores whether the element at a certain stack position is a duplicate.
|
private static CleaningLongHashMap<RecorderElement[]> |
STACKPOOL
Stores the stack pool, i.e. the pool of stack copies (without
duplicates).
|
private static int |
STACKPOOL_HASH_INCREMENT
An internal increment in case that hash values are identical.
|
private int |
stackSize
Stores the current size of the stack.
|
private long |
startCpuTimeTicks
Stores the number of assigned CPU time ticks when first entering the
thread.
|
private long |
startUseTimeTicks
Stores the CPU time ticks when using this thread started.
|
private long |
totalUseTimeTicks
Stores the total CPU usage time of this thread.
|
| Constructor and Description |
|---|
ThreadData() |
| Modifier and Type | Method and Description |
|---|---|
void |
copyStackFrom(ThreadData threadData)
Copies the stack entries from
threadData to this thread. |
RecorderElement[] |
createStackCopy()
Returns a the stack without duplicates.
|
void |
end(long threadTicks)
Ends recording for this thread as the thread ended.
|
long |
getCpuTimeTicks()
Returns the number of CPU time ticks allocated to this thread.
|
protected RecorderElement |
getRecorderElement()
Returns the recorder element to be used if no other recorder element
can be assigned.
|
RecorderElement |
getStackElement(int index)
Returns the element at the given stack position.
|
int |
getStackSize()
Returns the stack size.
|
long |
getTotalCpu()
Returns the total use of this thread in CPU ticks.
|
boolean |
isEnded()
Returns if recording is finished.
|
boolean |
isOnStack(RecorderElement elt,
boolean includeTop)
Returns whether the given
elt is on the stack. |
boolean |
isStackElementDuplicated(int index)
Returns whether the element at the given stack position is a duplicate.
|
void |
pop(RecorderElement elt)
Pushes the given recorder element (as a method call equivalent) from the
call stack.
|
void |
push(RecorderElement elt)
Pushes the recorder element (as a method call equivalent) to the call
stack.
|
static void |
releaseStack(RecorderElement[] stack)
Releases the given stack (to be obtained from
createStackCopy()). |
protected void |
setRecorderElement(RecorderElement recorderElement)
Changes the recorder element to be used if no other recorder element
can be assigned.
|
int |
stackIndex(RecorderElement elt)
Returns the index of the given element.
|
int |
stackSize()
Returns the size of the stack.
|
void |
start(long threadTicks)
Starts recording for this thread (again) as the thread was created or
reused.
|
(package private) void |
startTimeRecording(long nanoTime,
long threadTicks)
Is called to notify about the start of recording.
|
(package private) void |
stopTimeRecording(long nanoTime,
long threadTicks)
Is called to notify the end of recording.
|
RecorderElement |
top()
Returns the top of the call stack.
|
RecorderElement |
top(int varId)
Returns the top of the call stack and the top of the elements
with same
varId. |
java.lang.String |
toString()
Returns a textual description of this instance for debugging.
|
private static final CleaningLongHashMap<RecorderElement[]> STACKPOOL
private static final int STACKPOOL_HASH_INCREMENT
private static final int STACK_INCREMENT
private long startUseTimeTicks
totalUseTimeTicks.
This information should not be confused with cpuTimeTicks as
that time information needs to be collected in pairs of start/stop calls
and may be completed by this information when finalizing this thread.private long totalUseTimeTicks
private long cpuTimeTicks
private long startCpuTimeTicks
private long nesting
private RecorderElement recorderElement
private int stackSize
private RecorderElement[] stack
private boolean[] stackDuplicates
void startTimeRecording(long nanoTime,
long threadTicks)
nanoTime - the current time in nano secondsthreadTicks - the CPU time ticks consumed by this threadvoid stopTimeRecording(long nanoTime,
long threadTicks)
nanoTime - the current time in nano secondsthreadTicks - the CPU time ticks consumed by this threadpublic void start(long threadTicks)
threadTicks - the CPU time when this thread endspublic void end(long threadTicks)
threadTicks - the CPU time when this thread endspublic long getTotalCpu()
public boolean isEnded()
true if this thread is currently being recorded,
false elsepublic long getCpuTimeTicks()
public void push(RecorderElement elt)
elt - the recorder element to be pushedpublic void pop(RecorderElement elt)
elt - the recorder element to be popped (just to be sure)public RecorderElement top()
public int stackIndex(RecorderElement elt)
elt - the element to search for-1 of not found or the index otherwisepublic int stackSize()
public RecorderElement getStackElement(int index)
index - the index to return the element forjava.lang.ArrayIndexOutOfBoundsException - in case that the index is invalidpublic boolean isStackElementDuplicated(int index)
index - the index to return the element forjava.lang.ArrayIndexOutOfBoundsException - in case that the index is invalidpublic boolean isOnStack(RecorderElement elt, boolean includeTop)
elt is on the stack.elt - the element to search forincludeTop - include the top element or nottrue if elt is on the stack,public RecorderElement top(int varId)
varId.varId - the variability identification to be searched forvarIdpublic int getStackSize()
public java.lang.String toString()
toString in class java.lang.Objectprotected RecorderElement getRecorderElement()
protected void setRecorderElement(RecorderElement recorderElement)
recorderElement - new the recorder element (may be null)public void copyStackFrom(ThreadData threadData)
threadData to this thread.threadData - the object to copy frompublic RecorderElement[] createStackCopy()
STACKPOOLpublic static void releaseStack(RecorderElement[] stack)
createStackCopy()).stack - the stack to be released