ur_rna.Utilities

## Class StopWatch

- java.lang.Object
- - ur_rna.Utilities.StopWatch

-     public class StopWatch
      extends java.lang.Object

  Class used for debugging and diagnostics to display the ellapsed time for sections of code at runtime. Use the start, stop, reset, and restart methods to determine when the timer is running. Use the elapsed, println and prinf functions to determine the ellapsed time and/or output debug messages.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.io.PrintWriter` | `defaultOutput`
    `private java.io.PrintWriter` | `out`
    `private long` | `time`
    `static java.util.Map<java.lang.String,StopWatch>` | `watches`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StopWatch()`
    `StopWatch(boolean start)`
    `StopWatch(boolean start, java.io.PrintStream output)`
    `StopWatch(boolean start, java.io.PrintWriter output)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clearNamed()` Remove all named StopWatches
    `static StopWatch` | `create(java.lang.String name, boolean started)` Create a new named StopWatch and optionally start it if `started` is true.
    `long` | `elapsed()` The total elapsed time in milliseconds.
    `static long` | `elapsed(java.lang.String watchName)` Get the elapsed time of the named StopWatch.
    `static StopWatch` | `enter(java.lang.String watchName)` Gets the named StopWatch and starts it.
    `static StopWatch` | `exit(java.lang.String watchName)` Gets the named StopWatch and stops it.
    `static StopWatch` | `get(java.lang.String name)` Get named StopWatch if it exists.
    `static StopWatch` | `get(java.lang.String name, boolean createStarted)` Get named StopWatch if it exists.
    `boolean` | `isStarted()`
    `void` | `printAll()` Prints the elapsed time and current state of all named StopWatches.
    `void` | `printAll(long totalElapsed)` Prints the elapsed time and current state of all named StopWatches
    `void` | `printAll(java.lang.String format, long totalElapsed)` Prints the elapsed time and current state of all named StopWatches using the specified format.
    `StopWatch` | `printf(java.lang.String message, java.lang.Object... args)`
    `static StopWatch` | `printf(java.lang.String watchName, java.lang.String message, java.lang.Object... args)` Write a message to the named StopWatch.
    `StopWatch` | `println(java.lang.String message)`
    `static StopWatch` | `println(java.lang.String watchName, java.lang.String message)` Write a message to the named StopWatch.
    `StopWatch` | `reset()` Reset elapsed time to 0 and stop the timer.
    `StopWatch` | `restart()` Reset elapsed time to 0 and start the timer.
    `StopWatch` | `start()` Start the timer.
    `StopWatch` | `stop()` Stop the timer, but store the elapsed time so that when `start()` is called, the elapsed time will continue to increase.
    `static long` | `time()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### defaultOutput

          public static java.io.PrintWriter defaultOutput

    - #### out

          private java.io.PrintWriter out

    - #### time

          private long time

    - #### watches

          public static final java.util.Map<java.lang.String,StopWatch> watches

  - ### Constructor Detail

    - #### StopWatch

          public StopWatch()

    - #### StopWatch

          public StopWatch(boolean start)

    - #### StopWatch

          public StopWatch(boolean start,
                           java.io.PrintStream output)

    - #### StopWatch

          public StopWatch(boolean start,
                           java.io.PrintWriter output)

  - ### Method Detail

    - #### clearNamed

          public void clearNamed()

      Remove all named StopWatches

    - #### create

          public static StopWatch create(java.lang.String name,
                                         boolean started)

      Create a new named StopWatch and optionally start it if `started` is true. A KeyAlreadyExistsException is thrown if the named StopWatch already exists.

    - #### elapsed

          public long elapsed()

      The total elapsed time in milliseconds.

    - #### elapsed

          public static long elapsed(java.lang.String watchName)

      Get the elapsed time of the named StopWatch.

    - #### enter

          public static StopWatch enter(java.lang.String watchName)

      Gets the named StopWatch and starts it. If it doesn't already exist, it will be created.

    - #### exit

          public static StopWatch exit(java.lang.String watchName)

      Gets the named StopWatch and stops it. If it doesn't already exist, it will be created.

    - #### get

          public static StopWatch get(java.lang.String name)

      Get named StopWatch if it exists. Otherwise return null.

    - #### get

          public static StopWatch get(java.lang.String name,
                                      boolean createStarted)

      Get named StopWatch if it exists. Otherwise create it and optionally start it if createStarted is true.

    - #### isStarted

          public boolean isStarted()

    - #### printAll

          public void printAll()

      Prints the elapsed time and current state of all named StopWatches. Also calculates the percentage of each StopWatch relative to the totalElapsed time. If totalElapsed is less than or equal to 0, percentages are not calculated.

    - #### printAll

          public void printAll(long totalElapsed)

      Prints the elapsed time and current state of all named StopWatches

    - #### printAll

          public void printAll(java.lang.String format,
                               long totalElapsed)

      Prints the elapsed time and current state of all named StopWatches using the specified format. Use positional formatting 1=Elapsed Time, 2=State (on/off), 3=Name e.g. `"\t%1$5d\t%2$3s\t%2$s%n"`

    - #### printf

          public StopWatch printf(java.lang.String message,
                                  java.lang.Object... args)

    - #### printf

          public static StopWatch printf(java.lang.String watchName,
                                         java.lang.String message,
                                         java.lang.Object... args)

      Write a message to the named StopWatch.

    - #### println

          public StopWatch println(java.lang.String message)

    - #### println

          public static StopWatch println(java.lang.String watchName,
                                          java.lang.String message)

      Write a message to the named StopWatch.

    - #### reset

          public StopWatch reset()

      Reset elapsed time to 0 and stop the timer.

    - #### restart

          public StopWatch restart()

      Reset elapsed time to 0 and start the timer.

    - #### start

          public StopWatch start()

      Start the timer. If it is already running, this has no effect.

    - #### stop

          public StopWatch stop()

      Stop the timer, but store the elapsed time so that when `start()` is called, the elapsed time will continue to increase. If the timer is already stopped, this has no effect.

    - #### time

          public static long time()