]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: stopwatch.h | |
3 | // Purpose: interface of wxStopWatch | |
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 | @see wxTimer | |
32 | */ | |
33 | class wxStopWatch | |
34 | { | |
35 | public: | |
36 | /** | |
37 | Constructor. This starts the stop watch. | |
38 | */ | |
39 | wxStopWatch(); | |
40 | ||
41 | /** | |
42 | Pauses the stop watch. Call Resume() to resume | |
43 | time measuring again. | |
44 | If this method is called several times, @c Resume() must be called the same | |
45 | number of times to really resume the stop watch. You may, however, call | |
46 | Start() to resume it unconditionally. | |
47 | */ | |
48 | void Pause(); | |
49 | ||
50 | /** | |
51 | Resumes the stop watch which had been paused with | |
52 | Pause(). | |
53 | */ | |
54 | void Resume(); | |
55 | ||
56 | /** | |
57 | (Re)starts the stop watch with a given initial value. | |
58 | */ | |
59 | void Start(long milliseconds = 0); | |
60 | ||
61 | /** | |
62 | Returns the time in milliseconds since the start (or restart) or the last call | |
63 | of | |
64 | Pause(). | |
65 | */ | |
66 | long Time() const; | |
67 | }; | |
68 | ||
69 | ||
70 | ||
71 | // ============================================================================ | |
72 | // Global functions/macros | |
73 | // ============================================================================ | |
74 | ||
75 | /** @ingroup group_funcmacro_time */ | |
76 | //@{ | |
77 | ||
78 | /** | |
79 | Returns the number of seconds since local time 00:00:00 Jan 1st 1970. | |
80 | ||
81 | @see wxDateTime::Now() | |
82 | ||
83 | @header{wx/stopwatch.h} | |
84 | */ | |
85 | long wxGetLocalTime(); | |
86 | ||
87 | /** | |
88 | Returns the number of milliseconds since local time 00:00:00 Jan 1st 1970. | |
89 | ||
90 | @see wxDateTime::Now(), wxLongLong | |
91 | ||
92 | @header{wx/stopwatch.h} | |
93 | */ | |
94 | wxLongLong wxGetLocalTimeMillis(); | |
95 | ||
96 | /** | |
97 | Returns the number of seconds since GMT 00:00:00 Jan 1st 1970. | |
98 | ||
99 | @see wxDateTime::Now() | |
100 | ||
101 | @header{wx/stopwatch.h} | |
102 | */ | |
103 | long wxGetUTCTime(); | |
104 | ||
105 | //@} | |
106 |