]> git.saurik.com Git - wxWidgets.git/blob - interface/stopwatch.h
a94d6add2098d1e0c36cf34f32970d0db897c9bf
[wxWidgets.git] / interface / stopwatch.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: stopwatch.h
3 // Purpose: documentation for wxStopWatch class
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxStopWatch
11 @wxheader{stopwatch.h}
12
13 The wxStopWatch class allow you to measure time intervals. For example, you may
14 use it to measure the time elapsed by some function:
15
16 @code
17 wxStopWatch sw;
18 CallLongRunningFunction();
19 wxLogMessage("The long running function took %ldms to execute",
20 sw.Time());
21 sw.Pause();
22 ... stopwatch is stopped now ...
23 sw.Resume();
24 CallLongRunningFunction();
25 wxLogMessage("And calling it twice took $ldms in all", sw.Time());
26 @endcode
27
28 @library{wxbase}
29 @category{misc}
30
31 @seealso
32 wxTimer
33 */
34 class wxStopWatch
35 {
36 public:
37 /**
38 Constructor. This starts the stop watch.
39 */
40 wxStopWatch();
41
42 /**
43 Pauses the stop watch. Call Resume() to resume
44 time measuring again.
45 If this method is called several times, @c Resume() must be called the same
46 number of times to really resume the stop watch. You may, however, call
47 Start() to resume it unconditionally.
48 */
49 void Pause();
50
51 /**
52 Resumes the stop watch which had been paused with
53 Pause().
54 */
55 void Resume();
56
57 /**
58 (Re)starts the stop watch with a given initial value.
59 */
60 void Start(long milliseconds = 0);
61
62 /**
63 Returns the time in milliseconds since the start (or restart) or the last call
64 of
65 Pause().
66 */
67 long Time();
68 };
69
70
71 // ============================================================================
72 // Global functions/macros
73 // ============================================================================
74
75 /**
76 Returns the number of seconds since local time 00:00:00 Jan 1st 1970.
77
78 @see wxDateTime::Now
79 */
80 long wxGetLocalTime();
81
82 /**
83 Returns the number of seconds since GMT 00:00:00 Jan 1st 1970.
84
85 @see wxDateTime::Now
86 */
87 long wxGetUTCTime();
88
89 /**
90 Returns the number of milliseconds since local time 00:00:00 Jan 1st 1970.
91
92 @see wxDateTime::Now, wxLongLong
93 */
94 wxLongLong wxGetLocalTimeMillis();
95