public class StopWatch extends java.lang.Object
Based on the Spring StopWatch class, but supporting nested tasks
Modifiers | Name | Description |
---|---|---|
static class |
StopWatch.TaskInfo |
Inner class to hold data about one task executed within the stop watch. |
Modifiers | Name | Description |
---|---|---|
private java.lang.String |
currentTaskName |
Name of the current task |
private java.lang.String |
id |
Identifier of this stop watch. |
private StopWatch.TaskInfo |
lastTaskInfo |
|
private boolean |
running |
Is the stop watch currently running? |
private java.util.Deque<TaskInfo> |
runningTasks |
|
private int |
taskCount |
|
private java.util.Deque<TaskInfo> |
taskList |
|
private long |
totalTimeMillis |
Total running time |
Type Params | Return Type | Name and description |
---|---|---|
|
public int |
compare(StopWatch.TaskInfo o1, StopWatch.TaskInfo o2) |
|
public void |
complete() |
|
public StopWatch.TaskInfo |
getLastTaskInfo() Return the last task as a TaskInfo object. |
|
public java.lang.String |
getLastTaskName() Return the name of the last task. |
|
public long |
getLastTaskTimeMillis() Return the time taken by the last task. |
|
public int |
getTaskCount() Return the number of tasks timed. |
|
public StopWatch.TaskInfo[] |
getTaskInfo() Return an array of the data for tasks performed. |
|
public long |
getTotalTimeMillis() Return the total time in milliseconds for all tasks. |
|
public double |
getTotalTimeSeconds() Return the total time in seconds for all tasks. |
|
public boolean |
isRunning() Return whether the stop watch is currently running. |
|
public java.lang.String |
prettyPrint() Return a string with a table describing all tasks performed. |
|
public java.lang.String |
shortSummary() Return a short description of the total running time. |
|
public void |
start() Start an unnamed task. |
|
public void |
start(java.lang.String taskName) Start a named task. |
|
public void |
stop() Stop the current task. |
|
public java.lang.String |
toString() Return an informative string describing all tasks performed For custom reporting, call getTaskInfo() and use the task info directly. |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Name of the current task
Identifier of this stop watch. Handy when we have output from multiple stop watches and need to distinguish between them in log or console output.
Is the stop watch currently running?
Total running time
Construct a new stop watch. Does not start any task.
Construct a new stop watch with the given id. Does not start any task.
id
- identifier for this stop watch.
Handy when we have output from multiple stop watches
and need to distinguish between them.Return the last task as a TaskInfo object.
Return the name of the last task.
Return the time taken by the last task.
Return the number of tasks timed.
Return an array of the data for tasks performed.
Return the total time in milliseconds for all tasks.
Return the total time in seconds for all tasks.
Return whether the stop watch is currently running.
Return a string with a table describing all tasks performed. For custom reporting, call getTaskInfo() and use the task info directly.
Return a short description of the total running time.
Start an unnamed task. The results are undefined if stop() or timing methods are called without invoking this method.
Start a named task. The results are undefined if stop() or timing methods are called without invoking this method.
taskName
- the name of the task to startStop the current task. The results are undefined if timing methods are called without invoking at least one pair start() / stop() methods.
Return an informative string describing all tasks performed
For custom reporting, call getTaskInfo()
and use the task info directly.