| |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Simple stop watch, allowing for timing of a number of tasks, exposing total running time and running time for each named task. Conceals use of System.currentTimeMillis(), improving the readability of application code and reducing the likelihood of calculation errors.
Note that this object is not designed to be threadsafe, and does not use synchronization or threading. Therefore it is safe to invoke it from EJBs.
This class is normally used to verify performance during proof-of-concepts and in development, rather than as part of production applications.
| Inner Class Summary | |
public static class | StopWatch.TaskInfo Inner class to hold data about one task executed within the stopwatch |
| Constructor Summary | |
StopWatch()Construct a new stop watch. | |
StopWatch(String id)Construct a new stop watch with the given id. | |
| Method Summary | |
boolean | getKeepTaskList() |
long | getLastInterval()Returns the time taken by the last operation. |
int | getTaskCount()Returns the number of tasks timed. |
TaskInfo[] | getTaskInfo()Returns an array of the data for tasks performed. |
long | getTotalTime()Returns the total time in milliseconds for all tasks. |
double | getTotalTimeSecs()Returns the total time in seconds for all tasks. |
boolean | isRunning()Returns whether the stopwatch is currently running. |
String | prettyPrint()Returns a string with a table describing all tasks performed. |
void | setKeepTaskList(boolean keepTaskList)Determines whether TaskInfo array is built over time. |
String | shortSummary()Returns a short description of the total running time. |
void | start(String task)Start a named task. |
void | stop()Stop the current task. |
String | toString()Returns an informative string describing all tasks performed For custom reporting, call getTaskInfo() and use the task info directly. |
| Constructor Detail |
public StopWatch()
public StopWatch(String id)
| Method Detail |
public boolean getKeepTaskList()
public long getLastInterval()
throws java.lang.IllegalStateException
public int getTaskCount()
public TaskInfo[] getTaskInfo()
public long getTotalTime()
public double getTotalTimeSecs()
public boolean isRunning()
public String prettyPrint()
public void setKeepTaskList(boolean keepTaskList)
public String shortSummary()
public void start(String task)
throws java.lang.IllegalStateException
public void stop()
throws java.lang.IllegalStateException
public String toString()
| Association Links |
to Class java.lang.String
to Class java.lang.String
to Class org.springframework.util.StopWatch.TaskInfo
| |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||