Stop watch with nano second : StopWatch « Development Class « Java






Stop watch with nano second

  

public  class StopWatch {

  public final long t0 = System.currentTimeMillis();
  
  public final long n0 = System.nanoTime();

  static public StopWatch start() {
    return new StopWatch();
  }


  public long millisEllapsed() {
    return System.currentTimeMillis() - t0;
  }

  public double secondsEllapsed() {
    return millisEllapsed() / 1000.0;
  }

  public long nanoEllapsed() {
    return System.nanoTime() - n0;
  }

}

   
    
  








Related examples in the same category

1.StopWatch provides a convenient API for timings.
2.Simulates a stop watch with a lap counter.
3.Provides the programatic analog of a physical stop watch
4.Basic Timer
5.Provides various features related to the current date and timeProvides various features related to the current date and time
6.Simple stop watch
7.Some simple stop watch.
8.Stop Watch with PrintWriter
9.Stop Watch from JGraphT
10.StopWatch reports elapsed time between start and stop
11.Stopwatch is a debugging tool for manually profiling code execution
12.Your own timer
13.A class for timing things.
14.A convenience class to do code profiling.