StopWatch (Grails 3.2.9)
Date: 2017-04-26

Package: org.grails.core.util

## [Java] Class StopWatch

- org.grails.core.util.StopWatch

- Based on the Spring StopWatch class, but supporting nested tasks

  Authors:
    Rod Johnson
    Juergen Hoeller
    Sam Brannen
  Since:
    May 2, 2001

- - ### Nested Class Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `static class` | `StopWatch.TaskInfo` | Inner class to hold data about one task executed within the stop watch.

  - ### Constructor Summary

    Constructors
    Constructor and description
    `StopWatch ()` Construct a new stop watch.
    `StopWatch (java.lang.String id)` Construct a new stop watch with the given id.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `void` | `complete()`
    `` | `StopWatch.TaskInfo` | `getLastTaskInfo()` Return the last task as a TaskInfo object.
    `` | `java.lang.String` | `getLastTaskName()` Return the name of the last task.
    `` | `long` | `getLastTaskTimeMillis()` Return the time taken by the last task.
    `` | `int` | `getTaskCount()` Return the number of tasks timed.
    `` | `StopWatch.TaskInfo[]` | `getTaskInfo()` Return an array of the data for tasks performed.
    `` | `long` | `getTotalTimeMillis()` Return the total time in milliseconds for all tasks.
    `` | `double` | `getTotalTimeSeconds()` Return the total time in seconds for all tasks.
    `` | `boolean` | `isRunning()` Return whether the stop watch is currently running.
    `` | `java.lang.String` | `prettyPrint()` Return a string with a table describing all tasks performed.
    `` | `java.lang.String` | `shortSummary()` Return a short description of the total running time.
    `` | `void` | `start()` Start an unnamed task.
    `` | `void` | `start(java.lang.String taskName)` Start a named task.
    `` | `void` | `stop()` Stop the current task.
    `` | `java.lang.String` | `toString()` Return an informative string describing all tasks performed For custom reporting, call `getTaskInfo()` and use the task info directly.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), 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()`

- - ### Constructor Detail

    - #### public StopWatch()

      Construct a new stop watch. Does not start any task.

    - #### public StopWatch(java.lang.String id)

      Construct a new stop watch with the given id. Does not start any task.

      Parameters:
        `id` - identifier for this stop watch. Handy when we have output from multiple stop watches and need to distinguish between them.

  - ### Method Detail

    - #### 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. For custom reporting, call getTaskInfo() and use the task info directly.

    - #### public java.lang.String shortSummary()

      Return a short description of the total running time.

    - #### public void start()

      Start an unnamed task. The results are undefined if stop() or timing methods are called without invoking this method.

      See Also:
        stop()

    - #### public void start(java.lang.String taskName)

      Start a named task. The results are undefined if stop() or timing methods are called without invoking this method.

      Parameters:
        `taskName` - the name of the task to start
      See Also:
        stop()

    - #### public void stop()

      Stop the current task. The results are undefined if timing methods are called without invoking at least one pair start() / stop() methods.

      See Also:
        start()

    - #### @java.lang.Override public java.lang.String toString()

      Return an informative string describing all tasks performed For custom reporting, call `getTaskInfo()` and use the task info directly.