|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.svincent.util.Stopwatch
A timer class, useful for timing code.
I got tired of trying to figure out the Date class again and again, and having unpleasant output, because I was too lazy to process the output. But never again! Thanks to the wonders of Object Oriented Computing, I've written a Stopwatch class, which does all the work for me!
Using the Stopwatch is very easy. There are only two
interesting methods: reset and getMillis.
reset resets the stopwatch to zero.
Note that a newly constructed Stopwatch is implicitly reset.
getMillis returns the number of milliseconds that passed
since the last call to reset.
Note that printing a Stopwatch prints a human-readable representation
of the milliseconds which have passed (in hh:mm:ss.mmm format).
The following code block illustrates use of the Stopwatch.
Stopwatch stopwatch = new Stopwatch();
func(); Takes a while to run
Util.out.println(stopwatch);
| Constructor Summary | |
Stopwatch()
|
|
| Method Summary | |
long |
getMillis()
Return the number of milliseconds which have passed since we reset the stopwatch. |
static void |
main(java.lang.String[] argv)
Some test code. |
void |
reset()
Resets the time to 0. |
java.lang.String |
tag()
Returns a string representation of the current time. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
| Constructor Detail |
public Stopwatch()
| Method Detail |
public void reset()
(happens implicitly upon construction)
public java.lang.String tag()
This representation is in hh:mm:ss.mmm format, where
hh == hours, mm == minutes, ss == seconds, and mmm=milliseconds.
The hours field can be longer than two digits, if the
Stopwatch has run for longer than 99 hours. (This is unlikely to
be the case, however)
public java.lang.String toString()
public long getMillis()
reset
public static void main(java.lang.String[] argv)
throws java.lang.Exception
argv[0] is parsed into an int.Util.out.argv - The command line arguments.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
This is documentation for Moksa Prolog, which can be found at http://www.svincent.com/moksa/
Copyright © 1999 Shawn P. Vincent.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.