]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/stopwatch.h
Use shorter sleep times in wxStopWatch unit test.
[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
23324ae1
FM
28 @library{wxbase}
29 @category{misc}
7c913512 30
e54c96f1 31 @see wxTimer
23324ae1 32*/
7c913512 33class wxStopWatch
23324ae1
FM
34{
35public:
36 /**
37 Constructor. This starts the stop watch.
38 */
39 wxStopWatch();
40
41 /**
4701dc09
FM
42 Pauses the stop watch. Call Resume() to resume time measuring again.
43
23324ae1 44 If this method is called several times, @c Resume() must be called the same
7c913512 45 number of times to really resume the stop watch. You may, however, call
23324ae1
FM
46 Start() to resume it unconditionally.
47 */
48 void Pause();
49
50 /**
4701dc09 51 Resumes the stop watch which had been paused with Pause().
23324ae1
FM
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 /**
4701dc09
FM
61 Returns the time in milliseconds since the start (or restart) or the last
62 call of Pause().
23324ae1 63 */
328f5751 64 long Time() const;
23324ae1
FM
65};
66
67
e54c96f1 68
23324ae1
FM
69// ============================================================================
70// Global functions/macros
71// ============================================================================
72
b21126db 73/** @addtogroup group_funcmacro_time */
3950d49c
BP
74//@{
75
23324ae1
FM
76/**
77 Returns the number of seconds since local time 00:00:00 Jan 1st 1970.
7c913512 78
3950d49c
BP
79 @see wxDateTime::Now()
80
81 @header{wx/stopwatch.h}
23324ae1
FM
82*/
83long wxGetLocalTime();
84
85/**
3950d49c 86 Returns the number of milliseconds since local time 00:00:00 Jan 1st 1970.
7c913512 87
3950d49c
BP
88 @see wxDateTime::Now(), wxLongLong
89
90 @header{wx/stopwatch.h}
23324ae1 91*/
3950d49c 92wxLongLong wxGetLocalTimeMillis();
23324ae1
FM
93
94/**
3950d49c
BP
95 Returns the number of seconds since GMT 00:00:00 Jan 1st 1970.
96
97 @see wxDateTime::Now()
7c913512 98
3950d49c 99 @header{wx/stopwatch.h}
23324ae1 100*/
3950d49c
BP
101long wxGetUTCTime();
102
103//@}
23324ae1 104