1
2
3
4
5
6
7 package com.diasparsoftware.gsbase;
8
9 /***
10 * A simple timing device you can use to time any event.
11 *
12 * Sample use.
13 *
14 * <pre>
15 * Stopwatch stopwatch = new SystemClockStopwatch();
16 * // Your event starts...
17 * stopwatch.start();
18 * // Your event goes on...
19 * // Your event ends...
20 * stopwatch.stop();
21 * long timeInMilliseconds = stopwatch.getLastTime();
22 * stopwatch.reset();
23 * // Next event starts...
24 * stopwatch.start();
25 * // And so on...
26 * </pre>
27 *
28 * @version $Revision: 1.1 $
29 * @author <a href="mailto:jbr@diasparsoftware.com">J. B. Rainsberger</a>
30 */
31 public interface Stopwatch {
32 /***
33 * Start the stopwatch. This method will restart the stopwatch
34 * if it is already running.
35 */
36 void start();
37
38 /***
39 * Stops the stopwatch. This method has no effect if the stopwatch
40 * is already stopped.
41 *
42 */
43 void stop();
44
45 /***
46 * Resets the stopwatch, clearing the last time and preparing
47 * the shopwatch to be started again.
48 *
49 */
50 void reset();
51
52 /***
53 * Returns the last time interval recorded by the stopwatch.
54 * Formally, this is the difference in time between when you
55 * last invoked <code>stop()</code> after having invoked <code>start()</code>.
56 * @return The last time interval recorded by the stopwatch,
57 * or 0 if the stopwatch has been reset or never used.
58 */
59 long getLastTime();
60 }