Class OpTimer

  • public class OpTimer
    extends Object
    Provides a stop watch for timing a single type of event. This code is based on the org.apache.hadoop.util.StopWatch available in hadoop 2.7.0
    • Constructor Detail

      • OpTimer

        public OpTimer()
    • Method Detail

      • isRunning

        public boolean isRunning()
        Returns timer running state
        true if timer is running
      • reset

        public OpTimer reset()
        Stops timer instance and current elapsed time to 0.
        this instance for fluent chaining
      • now

        public long now​(TimeUnit timeUnit)
        Converts current timer value to specific unit. The conversion to courser granularities truncate with loss of precision.
        timeUnit - the time unit that will converted to.
        truncated time in unit of specified time unit.
      • scale

        public double scale​(TimeUnit timeUnit)
        Returns the current elapsed time scaled to the provided time unit. This method does not truncate like now(TimeUnit) but returns the value as a double.

        Note: this method is not included in the hadoop 2.7 org.apache.hadoop.util.StopWatch class. If that class is adopted, then provisions will be required to replace this method.

        timeUnit - the time unit to scale the elapsed time to.
        the elapsed time of this instance scaled to the provided time unit.
      • now

        public long now()
        Returns current timer elapsed time as nanoseconds.
        elapsed time in nanoseconds.
      • toString

        public String toString()
        Return the current elapsed time in nanoseconds as a string.
        toString in class Object
        timer elapsed time as nanoseconds.