]> git.saurik.com Git - wxWidgets.git/blame - interface/stopwatch.h
Patch from Utensil Candel with large improvements to the samples documentation, and...
[wxWidgets.git] / interface / 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$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxStopWatch
11 @wxheader{stopwatch.h}
7c913512 12
23324ae1
FM
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:
7c913512 15
23324ae1
FM
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
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 /**
7c913512 42 Pauses the stop watch. Call Resume() to resume
23324ae1 43 time measuring again.
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 /**
7c913512 51 Resumes the stop watch which had been paused with
23324ae1
FM
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
7c913512 63 of
23324ae1
FM
64 Pause().
65 */
328f5751 66 long Time() const;
23324ae1
FM
67};
68
69
e54c96f1 70
23324ae1
FM
71// ============================================================================
72// Global functions/macros
73// ============================================================================
74
3950d49c
BP
75/** @ingroup group_funcmacro_time */
76//@{
77
23324ae1
FM
78/**
79 Returns the number of seconds since local time 00:00:00 Jan 1st 1970.
7c913512 80
3950d49c
BP
81 @see wxDateTime::Now()
82
83 @header{wx/stopwatch.h}
23324ae1
FM
84*/
85long wxGetLocalTime();
86
87/**
3950d49c 88 Returns the number of milliseconds since local time 00:00:00 Jan 1st 1970.
7c913512 89
3950d49c
BP
90 @see wxDateTime::Now(), wxLongLong
91
92 @header{wx/stopwatch.h}
23324ae1 93*/
3950d49c 94wxLongLong wxGetLocalTimeMillis();
23324ae1
FM
95
96/**
3950d49c
BP
97 Returns the number of seconds since GMT 00:00:00 Jan 1st 1970.
98
99 @see wxDateTime::Now()
7c913512 100
3950d49c 101 @header{wx/stopwatch.h}
23324ae1 102*/
3950d49c
BP
103long wxGetUTCTime();
104
105//@}
23324ae1 106