]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/stopwatch.h
Move code removing "-psn_xxx" command line arguments to common code.
[wxWidgets.git] / interface / wx / stopwatch.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: stopwatch.h
e54c96f1 3// Purpose: interface of wxStopWatch
23324ae1 4// Author: wxWidgets team
526954c5 5// Licence: wxWindows licence
23324ae1
FM
6/////////////////////////////////////////////////////////////////////////////
7
8/**
9 @class wxStopWatch
7c913512 10
4701dc09
FM
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:
7c913512 14
23324ae1 15 @code
4701dc09 16 wxStopWatch sw;
23324ae1
FM
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
8c6471af 27 Since wxWidgets 2.9.3 this class uses @c QueryPerformanceCounter()
54647bb7
VZ
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
23324ae1
FM
34 @library{wxbase}
35 @category{misc}
7c913512 36
e54c96f1 37 @see wxTimer
23324ae1 38*/
7c913512 39class wxStopWatch
23324ae1
FM
40{
41public:
42 /**
43 Constructor. This starts the stop watch.
44 */
45 wxStopWatch();
46
47 /**
4701dc09
FM
48 Pauses the stop watch. Call Resume() to resume time measuring again.
49
23324ae1 50 If this method is called several times, @c Resume() must be called the same
7c913512 51 number of times to really resume the stop watch. You may, however, call
23324ae1
FM
52 Start() to resume it unconditionally.
53 */
54 void Pause();
55
56 /**
4701dc09 57 Resumes the stop watch which had been paused with Pause().
23324ae1
FM
58 */
59 void Resume();
60
61 /**
62 (Re)starts the stop watch with a given initial value.
17d72a48
VZ
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.
23324ae1
FM
67 */
68 void Start(long milliseconds = 0);
69
70 /**
4701dc09
FM
71 Returns the time in milliseconds since the start (or restart) or the last
72 call of Pause().
b0ec0023
VZ
73
74 @see TimeInMicro()
23324ae1 75 */
328f5751 76 long Time() const;
b0ec0023
VZ
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;
23324ae1
FM
88};
89