net.sf.antcontrib.perf
public class StopWatch extends Object
StopWatch sw = new StopWatch(); // automatically starts // do something here... sw.stop(); System.out.println(sw.toString()); // print the total sw.start(); // restart the stopwatch // do some more things... sw.stop(); System.out.println(sw.format(sw.elapsed()); // print the time since the last start System.out.println(sw.toString()); // print the cumulative total
Developed for use with Antelope, migrated to ant-contrib Oct 2003.
Version: $Revision: 1.3 $
Constructor Summary | |
---|---|
StopWatch()
Starts the stopwatch. | |
StopWatch(String name)
Starts the stopwatch. |
Method Summary | |
---|---|
long | elapsed()
Elapsed time, difference between the last start time and now.
|
String | format(long ms)
Formats the given time into decimal seconds. |
String | getName() |
static void | main(String[] args) |
long | start()
Starts/restarts the stopwatch. |
long | stop()
Stops the stopwatch.
|
String | toString()
Returns the total elapsed time of the stopwatch formatted in decimal seconds. |
long | total()
Total cumulative elapsed time.
|
Parameters: name an identifying name for this StopWatch
Returns: the elapsed time
Returns: the time formatted as mm:ss.ddd
Returns: the name of this StopWatch
stop
must be called prior
to restart.
Returns: the start time, the long returned System.currentTimeMillis().
Returns: the stop time, the long returned System.currentTimeMillis().
Returns: [name: mm:ss.ddd]
Returns: the total time