public class TimerDriver
{
public static void main( String args[] )
{
Stopwatch seiko = new Stopwatch();
seiko.startTimer();
for(int ctr = 0; ctr < Integer.MAX_VALUE; ctr++)
{
// what do you want to time??
// do nothing
}
seiko.endTimer();
seiko.printElapsedTime();
} // end method main
} // end class TimerDriver
public class Stopwatch
{
private long startTime;
private long endTime;
public Stopwatch()
{
startTime = 0;
endTime = 0;
} // end constructor StopWatch
public void startTimer()
{
startTime = System.nanoTime();
} // end method startTimer
public void endTimer()
{
endTime = System.nanoTime();
} // end method endTimer
public void printElapsedTime()
{
System.out.println( "Elapsed time in nanoseconds is: " + (endTime - startTime));
} // end method printElaspedTime
} // end class Stopwatch