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