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