open class StopWatch
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 thread-safe and does not use synchronization.
This class is normally used to verify performance during proof-of-concepts and in development, rather than as part of production applications.
Author
Rod Johnson
Author
Juergen Hoeller
Author
Sam Brannen
Since
May 2, 2001
StopWatch()
Construct a new stop watch. Does not start any task. StopWatch(id: String)
Construct a new stop watch with the given id. Does not start any task. |
open fun currentTaskName(): String
Return the name of the currently running task, if any. |
|
open fun getId(): String
Return the id of this stop watch, as specified on construction. |
|
open fun getLastTaskInfo(): TaskInfo
Return the last task as a TaskInfo object. |
|
open fun getLastTaskName(): String
Return the name of the last task. |
|
open fun getLastTaskTimeMillis(): Long
Return the time taken by the last task. |
|
open fun getTaskCount(): Int
Return the number of tasks timed. |
|
open fun getTaskInfo(): Array<TaskInfo>
Return an array of the data for tasks performed. |
|
open fun getTotalTimeMillis(): Long
Return the total time in milliseconds for all tasks. |
|
open fun getTotalTimeSeconds(): Double
Return the total time in seconds for all tasks. |
|
open fun isRunning(): Boolean
Return whether the stop watch is currently running. |
|
open fun prettyPrint(): String
Return a string with a table describing all tasks performed. For custom reporting, call getTaskInfo() and use the task info directly. |
|
open fun setKeepTaskList(keepTaskList: Boolean): Unit
Determine whether the TaskInfo array is built over time. Set this to "false" when using a StopWatch for millions of intervals, or the task info structure will consume excessive memory. Default is "true". |
|
open fun shortSummary(): String
Return a short description of the total running time. |
|
open fun start(): Unit
Start an unnamed task. The results are undefined if open fun start(taskName: String): Unit
Start a named task. The results are undefined if |
|
open fun stop(): Unit
Stop the current task. The results are undefined if timing methods are called without invoking at least one pair |
|
open fun toString(): String
Return an informative string describing all tasks performed For custom reporting, call |