Documentation of 'org.hsqldb.lib.StopWatch' Java class
StopWatch
org.hsqldb.lib

Class StopWatch



  • public class StopWatch
    extends java.lang.Object
    Provides the programatic analog of a physical stop watch.

    The watch can be started, stopped and zeroed and can be queried for elapsed running time. The watch accumulates elapsed time over starts and stops such that only the time actually spent running is recorded. If the watch is zeroed, then the accumulated time is discarded and the watch starts again with zero acumulated time.

    Since:
    1.7.2
    • Constructor Summary

      Constructors 
      Constructor and Description
      StopWatch()
      Creates, zeros, and starts a new StopWatch
      StopWatch(boolean start)
      Creates, zeros, and starts a new StopWatch
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      long currentElapsedTime()
      Retrieves the accumulated time this object has spent running since it was last started.
      java.lang.String currentElapsedTimeToMessage(java.lang.String prefix)
      Retrieves prefix + " in " + elapsedTime() + " ms."
      long elapsedTime()
      Retrieves the accumulated time this object has spent running since it was last zeroed.
      java.lang.String elapsedTimeToMessage(java.lang.String prefix)
      Retrieves prefix + " in " + elapsedTime() + " ms."
      void mark() 
      void start()
      Ensures that this object is in the running state.
      void stop()
      Ensures that this object is in the stopped state.
      java.lang.String toString()
      Retrieves the internal state of this object, as a String.
      void zero()
      Zeros accumulated running time and restarts this object.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • StopWatch

        public StopWatch()
        Creates, zeros, and starts a new StopWatch
      • StopWatch

        public StopWatch(boolean start)
        Creates, zeros, and starts a new StopWatch
    • Method Detail

      • elapsedTime

        public long elapsedTime()
        Retrieves the accumulated time this object has spent running since it was last zeroed.
        Returns:
        the accumulated time this object has spent running since it was last zeroed.
      • currentElapsedTime

        public long currentElapsedTime()
        Retrieves the accumulated time this object has spent running since it was last started.
        Returns:
        the accumulated time this object has spent running since it was last started.
      • zero

        public void zero()
        Zeros accumulated running time and restarts this object.
      • start

        public void start()
        Ensures that this object is in the running state. If this object is not running, then the call has the effect of setting the startTime attribute to the current value of System.currentTimeMillis() and setting the running attribute to true.
      • stop

        public void stop()
        Ensures that this object is in the stopped state. If this object is in the running state, then this has the effect of adding to the total attribute the elapsed time since the last transition from stopped to running state and sets the running attribute to false. If this object is not in the running state, this call has no effect.
      • mark

        public void mark()
      • elapsedTimeToMessage

        public java.lang.String elapsedTimeToMessage(java.lang.String prefix)
        Retrieves prefix + " in " + elapsedTime() + " ms."
        Parameters:
        prefix - The string to use as a prefix
        Returns:
        prefix + " in " + elapsedTime() + " ms."
      • currentElapsedTimeToMessage

        public java.lang.String currentElapsedTimeToMessage(java.lang.String prefix)
        Retrieves prefix + " in " + elapsedTime() + " ms."
        Parameters:
        prefix - The string to use as a prefix
        Returns:
        prefix + " in " + elapsedTime() + " ms."
      • toString

        public java.lang.String toString()
        Retrieves the internal state of this object, as a String. The retreived value is:
            super.toString() +
            "[running=" +
            running +
            ", startTime=" +
            startTime +
            ", total=" +
            total + "]";
         
        Overrides:
        toString in class java.lang.Object
        Returns:
        the state of this object, as a String

DataMelt 3.0 © DataMelt by jWork.ORG

Ads help maintain this website.