Class NanoTimer

java.lang.Object
org.apache.hadoop.hbase.io.hfile.NanoTimer

public class NanoTimer extends Object
A nano-second timer.

Copied from hadoop-3315 tfile. Remove after tfile is committed and use the tfile version of this class instead.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private long
     
    private long
     
    private boolean
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    NanoTimer(boolean start)
    Constructor Start the timer upon construction.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checking whether the timer is started
    static void
    main(String[] args)
    Simple tester.
    static String
    A utility method to format a time duration in nano seconds into a human understandable stirng.
    long
    Read the timer.
    private boolean
     
    void
    Reset the timer.
    void
    Start the timer.
    void
    Stop the timer.
    Format the elapsed time to a human understandable string.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • NanoTimer

      public NanoTimer(boolean start)
      Constructor Start the timer upon construction.
  • Method Details

    • start

      public void start()
      Start the timer. Note: No effect if timer is already started.
    • stop

      public void stop()
      Stop the timer. Note: No effect if timer is already stopped.
    • read

      public long read()
      Read the timer.
      Returns:
      the elapsed time in nano-seconds. Note: If the timer is never started before, -1 is returned.
    • reset

      public void reset()
      Reset the timer.
    • isStarted

      public boolean isStarted()
      Checking whether the timer is started
      Returns:
      true if timer is started.
    • toString

      public String toString()
      Format the elapsed time to a human understandable string. Note: If timer is never started, "ERR" will be returned.
      Overrides:
      toString in class Object
    • nanoTimeToString

      public static String nanoTimeToString(long t)
      A utility method to format a time duration in nano seconds into a human understandable stirng. Time duration in nano seconds.
      Returns:
      String representation.
    • readable

      private boolean readable()
    • main

      public static void main(String[] args)
      Simple tester.