|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.marringtons.time.Timer
Use to measure and print timing information in the code.
Timer timer = new Timer(); ..... String message = timer.toString(); // implicit stop ..... timer.println(); // implicit stop ..... Log.message( timer.stop()); // record it to the log (could have used toString() ..... System.out.println( timer); // stop is implicitAll the examples above will display same times from the first stop. To get the time between 2 points after the creation, use timer.reset() at the start point.
| Constructor Summary | |
Timer()
The default constructor will instantiate and start a timer object. |
|
Timer(String message)
This constructor attaches a text message to a timer for later display. |
|
| Method Summary | |
void |
print()
Stop timer and print result to stdout |
void |
print(String msg)
Stop timer and print result to stdout. |
void |
println()
Stop timer and print result to stdout including a carriage-return |
void |
println(String msg)
Stop timer and print result to stdout including a carriage-return |
void |
reset()
Reset the start time (same as creating a new object) |
float |
secondsElapsed()
Stops timer if running and returns seconds elapsed since creation or last reset |
String |
stop()
Sets the end time |
String |
stop(String msg)
Sets the end time and returns the elapsed time and message. |
String |
toString()
Returns a string with attached message and elapsed seconds in brackets. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public Timer()
public Timer(String message)
message - to display with timer.| Method Detail |
public void reset()
public String stop()
public String stop(String msg)
msg - to display with timer output.
public void print()
public void print(String msg)
msg - additional message to printpublic void println(String msg)
msg - additional message to printpublic void println()
public float secondsElapsed()
public String toString()
Object.toString()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||