Class StopWatch

java.lang.Object
org.slf4j.profiler.StopWatch
All Implemented Interfaces:
TimeInstrument

public class StopWatch extends Object implements TimeInstrument
A very basic TimeInstrument which can be started and stopped once and only once.
Author:
Ceki Gülcü
  • Constructor Details

    • StopWatch

      public StopWatch(String name)
  • Method Details

    • start

      public void start(String name)
      Description copied from interface: TimeInstrument
      Start this time instrument.
      Specified by:
      start in interface TimeInstrument
      Parameters:
      name - the name of this instrument
    • getName

      public String getName()
      Description copied from interface: TimeInstrument
      All time instruments are named entities.
      Specified by:
      getName in interface TimeInstrument
      Returns:
      the name of this instrument
    • stop

      public TimeInstrument stop()
      Description copied from interface: TimeInstrument
      Stop this time instrument.
      Specified by:
      stop in interface TimeInstrument
      Returns:
      this
    • stop

      public StopWatch stop(long stopTime)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • elapsedTime

      public final long elapsedTime()
      Description copied from interface: TimeInstrument
      Time elapsed between start and stop, in nanoseconds.
      Specified by:
      elapsedTime in interface TimeInstrument
      Returns:
      time elapsed in nanoseconds
    • getStatus

      public org.slf4j.profiler.TimeInstrumentStatus getStatus()
      Specified by:
      getStatus in interface TimeInstrument
    • print

      public void print()
      Description copied from interface: TimeInstrument
      Print information about this time instrument on the console.
      Specified by:
      print in interface TimeInstrument
    • log

      public void log()
      Description copied from interface: TimeInstrument
      If the time instrument has an associated logger, then log information about this time instrument. Note that StopWatch instances cannot log while Profiler instances can.
      Specified by:
      log in interface TimeInstrument