|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcommon.Timer
public class Timer
A class for measuring how much time a program spends doing certain operations. Each Timer object acts like a stopwatch that keeps track of an elapsed time. When you call the start method, the elapsed time starts increasing; when you call the stop method, it stops. Unlike a stopwatch, there is no "reset" method. There is also a static method printAllTimers which you can call at the end of a program to get the elapsed time for every timer created during this run of the program.
Constructor Summary | |
---|---|
Timer()
Creates a new Timer that will not be registered to have its its time printed by Timer.printAllTimers. |
|
Timer(java.lang.String name)
Creates a new Timer with the given name, and registers it so that its elapsed time will be printed by Timer.printAllTimers. |
Method Summary | |
---|---|
double |
elapsedTime()
Returns the total elapsed time in seconds. |
static void |
printAllTimers()
Prints the elapsed times for all timers created by the program. |
void |
start()
Starts the timer. |
void |
stop()
Stops the timer, and adds the time elapsed since the last call to start() to the running total. |
java.lang.String |
toString()
Returns a string containing this Timer's name and elapsed time. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Timer()
public Timer(java.lang.String name)
Method Detail |
---|
public final void start()
public final void stop()
public double elapsedTime()
public java.lang.String toString()
toString
in class java.lang.Object
public static void printAllTimers()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |