1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/stopwatch.h
3 // Purpose: wxStopWatch and global time-related functions
4 // Author: Julian Smart (wxTimer), Sylvain Bougnoux (wxStopWatch)
5 // Created: 26.06.03 (extracted from wx/timer.h)
7 // Copyright: (c) 1998-2003 wxWindows team
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_STOPWATCH_H_
12 #define _WX_STOPWATCH_H_
14 #include "wx/longlong.h"
16 // ----------------------------------------------------------------------------
17 // wxStopWatch: measure time intervals with up to 1ms resolution
18 // ----------------------------------------------------------------------------
22 class WXDLLIMPEXP_BASE wxStopWatch
25 // ctor starts the stop watch
26 wxStopWatch() { m_pauseCount
= 0; Start(); }
28 // start the stop watch at the moment t0
29 void Start(long t0
= 0);
31 // pause the stop watch
34 if ( !m_pauseCount
++ )
35 m_pause
= GetElapsedTime();
41 wxASSERT_MSG( m_pauseCount
> 0,
42 _T("Resuming stop watch which is not paused") );
44 if ( !--m_pauseCount
)
48 // get elapsed time since the last Start() in milliseconds
52 // returns the elapsed time since t0
53 long GetElapsedTime() const;
56 // the time of the last Start()
59 // the time of the last Pause() (only valid if m_pauseCount > 0)
62 // if > 0, the stop watch is paused, otherwise it is running
66 #endif // wxUSE_STOPWATCH
70 // Starts a global timer
71 // -- DEPRECATED: use wxStopWatch instead
72 void WXDLLIMPEXP_BASE
wxStartTimer();
74 // Gets elapsed milliseconds since last wxStartTimer or wxGetElapsedTime
75 // -- DEPRECATED: use wxStopWatch instead
76 long WXDLLIMPEXP_BASE
wxGetElapsedTime(bool resetTimer
= TRUE
);
78 #endif // wxUSE_LONGLONG
80 // ----------------------------------------------------------------------------
81 // global time functions
82 // ----------------------------------------------------------------------------
84 // Get number of seconds since local time 00:00:00 Jan 1st 1970.
85 extern long WXDLLIMPEXP_BASE
wxGetLocalTime();
87 // Get number of seconds since GMT 00:00:00, Jan 1st 1970.
88 extern long WXDLLIMPEXP_BASE
wxGetUTCTime();
91 // Get number of milliseconds since local time 00:00:00 Jan 1st 1970
92 extern wxLongLong WXDLLIMPEXP_BASE
wxGetLocalTimeMillis();
93 #endif // wxUSE_LONGLONG
95 #define wxGetCurrentTime() wxGetLocalTime()
97 #endif // _WX_STOPWATCH_H_