StopWatch (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.util, class: StopWatch

Package org.apache.hadoop.util

# Class StopWatch

java.lang.Object
org.apache.hadoop.util.StopWatch

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`

public class StopWatch extends Object implements Closeable
A simplified StopWatch implementation which can measure times in nanoseconds.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StopWatch()`
  `StopWatch(Timer timer)`
  Used for tests to be able to create a StopWatch which does not follow real time.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  `boolean`
  `isRunning()`
  The method is used to find out if the StopWatch is started.
  `long`
  `now()`
  `long`
  `now(TimeUnit timeUnit)`
  now.
  `StopWatch`
  `reset()`
  Reset elapsed time to zero and make the state of stopwatch stop.
  `StopWatch`
  `start()`
  Start to measure times and make the state of stopwatch running.
  `StopWatch`
  `stop()`
  Stop elapsed time and make the state of stopwatch stop.
  `String`
  `toString()`

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

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

- ## Constructor Details

  - ### StopWatch

    public StopWatch()

  - ### StopWatch

    public StopWatch(Timer timer)
    Used for tests to be able to create a StopWatch which does not follow real time.
    Parameters:
      `timer` - The timer to base this StopWatch's timekeeping off of.

- ## Method Details

  - ### isRunning

    public boolean isRunning()
    The method is used to find out if the StopWatch is started.
    Returns:
      boolean If the StopWatch is started.

  - ### start

    public StopWatch start()
    Start to measure times and make the state of stopwatch running.
    Returns:
      this instance of StopWatch.

  - ### stop

    public StopWatch stop()
    Stop elapsed time and make the state of stopwatch stop.
    Returns:
      this instance of StopWatch.

  - ### reset

    public StopWatch reset()
    Reset elapsed time to zero and make the state of stopwatch stop.
    Returns:
      this instance of StopWatch.

  - ### now

    public long now(TimeUnit timeUnit)
    now.
    Parameters:
      `timeUnit` - timeUnit.
    Returns:
      current elapsed time in specified timeunit.

  - ### now

    public long now()
    Returns:
      current elapsed time in nanosecond.

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### close

    public void close()
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `Closeable`