]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/stopwatch.h
Applied #15226 with modifications: wxRichTextCtrl: Implement setting properties with...
[wxWidgets.git] / interface / wx / stopwatch.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: stopwatch.h
3 // Purpose: interface of wxStopWatch
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
7
8 /**
9 @class wxStopWatch
10
11 The wxStopWatch class allow you to measure time intervals.
12
13 For example, you may use it to measure the time elapsed by some function:
14
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
26
27 Since wxWidgets 2.9.3 this class uses @c QueryPerformanceCounter()
28 function under MSW to measure the elapsed time. It provides higher
29 precision than the usual timer functions but can suffer from bugs in its
30 implementation in some Windows XP versions. If you encounter such problems,
31 installing a Microsoft hot fix from http://support.microsoft.com/?id=896256
32 could be necessary.
33
34 @library{wxbase}
35 @category{misc}
36
37 @see wxTimer
38 */
39 class wxStopWatch
40 {
41 public:
42 /**
43 Constructor. This starts the stop watch.
44 */
45 wxStopWatch();
46
47 /**
48 Pauses the stop watch. Call Resume() to resume time measuring again.
49
50 If this method is called several times, @c Resume() must be called the same
51 number of times to really resume the stop watch. You may, however, call
52 Start() to resume it unconditionally.
53 */
54 void Pause();
55
56 /**
57 Resumes the stop watch which had been paused with Pause().
58 */
59 void Resume();
60
61 /**
62 (Re)starts the stop watch with a given initial value.
63
64 The stopwatch will always be running after calling Start(), even if
65 Pause() had been called before and even if it had been called multiple
66 times.
67 */
68 void Start(long milliseconds = 0);
69
70 /**
71 Returns the time in milliseconds since the start (or restart) or the last
72 call of Pause().
73
74 @see TimeInMicro()
75 */
76 long Time() const;
77
78 /**
79 Returns elapsed time in microseconds.
80
81 This method is similar to Time() but returns the elapsed time in
82 microseconds and not milliseconds. Notice that not all platforms really
83 can measure times with this precision.
84
85 @since 2.9.3
86 */
87 wxLongLong TimeInMicro() const;
88 };
89