com.pelzer.util
Class StopWatch

java.lang.Object
  extended by com.pelzer.util.StopWatch

public class StopWatch
extends Object

This is a quick utility to aid in getting timing info for debugging/etc. Basic usage is:
StopWatch watch = new StopWatch(); watch.start(); // Calls an implicit reset(); sleep(1000); System.out.println(watch.getElapsed().toString); // Should be something like "00:00:01:00"; sleep(2000); watch.stop(); sleep(2000); System.out.println(watch.getElapsed().toString); // Should be something like "00:00:03:00";


Constructor Summary
StopWatch()
          Creates a new stopwatch.
 
Method Summary
 Timecode getElapsed()
          Can be called at any time, returns a SMPTE object with 1000 frames/sec (corresponding to milliseconds) representing the time elapsed since start() is called.
 boolean isRunning()
           
 void reset()
          Resets elapsed time to zero and stops the clock ticking.
 void start()
          If the clock is not ticking, resets the elapsed time reset() and then starts the clock.
 void stop()
          Stops the clock if it is running.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StopWatch

public StopWatch()
Creates a new stopwatch. You must call start() to begin timing.

Method Detail

reset

public void reset()
Resets elapsed time to zero and stops the clock ticking.


start

public void start()
If the clock is not ticking, resets the elapsed time reset() and then starts the clock.


stop

public void stop()
Stops the clock if it is running.


getElapsed

public Timecode getElapsed()
Can be called at any time, returns a SMPTE object with 1000 frames/sec (corresponding to milliseconds) representing the time elapsed since start() is called. If start has not been called, returns 0. If stop has not been called, returns the current elapsed time. Once stop is called, the elapsed time no longer increments, and is frozen.


isRunning

public boolean isRunning()


Copyright © 2012. All Rights Reserved.