Package com.norconex.commons.lang.time

# Class Timer

java.lang.Object
com.norconex.commons.lang.time.Timer

public final class Timer extends Object
Time the execution of arbitrary code and return the elapsed time.

Since:
  3.0.0

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static long`
  `time(Runnable runnable)`
  Returns the runnable execution time in milliseconds.
  `static Duration`
  `timeDuration(Runnable runnable)`
  Returns the runnable execution time as a `Duration`.
  `static StopWatch`
  `timeWatch(Runnable runnable)`
  Returns the runnable execution time as a stopped `StopWatch`.

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

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

- ## Method Details

  - ### time

    public static long time(Runnable runnable)
    Returns the runnable execution time in milliseconds.
    Parameters:
      `runnable` - the code to execute
    Returns:
      elapsed time in milliseconds

  - ### timeDuration

    public static Duration timeDuration(Runnable runnable)
    Returns the runnable execution time as a `Duration`.
    Parameters:
      `runnable` - the code to execute
    Returns:
      elapsed time as `Duration`

  - ### timeWatch

    public static StopWatch timeWatch(Runnable runnable)
    Returns the runnable execution time as a stopped `StopWatch`.
    Parameters:
      `runnable` - the code to execute
    Returns:
      elapsed time as a stopped `StopWatch`