com.comtrade.ecm.engine.util

## Class StopWatch

- java.lang.Object
- - com.comtrade.ecm.engine.util.StopWatch

-     public class StopWatch
      extends java.lang.Object

  Simulation of a stopwatch.
  Mesures the duration of a single process, but can sum durations of many of its iterations.
  All the method return an object, in order to enable "method chaining".

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `StopWatch()` Creates stopwatch without a name.
    `StopWatch(java.lang.String processName)` Creates stopwatch with a processName `processName`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `StopWatch` | `add()` Stops the measuring and adds the duration of the last iteration to a sum of all durations.
    `StopWatch` | `end()` Stops the measuring
    `long` | `getDuration()`
    `long` | `getSumOfDurations()`
    `java.lang.String` | `report()`
    `java.lang.String` | `reportDuration()`
    `StopWatch` | `reset()` Reseting sum of all durations
    `StopWatch` | `start()` Starts the measuring

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

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

- - ### Constructor Detail

    - #### StopWatch

          public StopWatch(java.lang.String processName)

      Creates stopwatch with a processName `processName`
      Parameters:
        `processName` - The name of a process (so that we can differ it from other processes)

    - #### StopWatch

          public StopWatch()

      Creates stopwatch without a name.

  - ### Method Detail

    - #### start

          public StopWatch start()

      Starts the measuring
      Returns:
        A reference to a `StopWatch` object

    - #### end

          public StopWatch end()

      Stops the measuring
      Returns:
        A reference to a `StopWatch` object

    - #### add

          public StopWatch add()

      Stops the measuring and adds the duration of the last iteration to a sum of all durations.
      Returns:
        A reference to a `StopWatch` object

    - #### reset

          public StopWatch reset()

      Reseting sum of all durations
      Returns:
        A reference to a `StopWatch` object

    - #### getDuration

          public long getDuration()

      Returns:
        Duration of the last iteration

    - #### getSumOfDurations

          public long getSumOfDurations()

      Returns:
        Duration of all iterations

    - #### report

          public java.lang.String report()

      Returns:
        Standard report about the duration of the last iteration

    - #### reportDuration

          public java.lang.String reportDuration()

      Returns:
        Standard report about the duration of all iterations