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 // ----------------------------------------------------------------------------
15 // wxStopWatch: measure time intervals with up to 1ms resolution
16 // ----------------------------------------------------------------------------
20 class WXDLLEXPORT_BASE wxStopWatch
23 // ctor starts the stop watch
24 wxStopWatch() { m_pauseCount
= 0; Start(); }
26 // start the stop watch at the moment t0
27 void Start(long t0
= 0);
29 // pause the stop watch
32 if ( !m_pauseCount
++ )
33 m_pause
= GetElapsedTime();
39 wxASSERT_MSG( m_pauseCount
> 0,
40 _T("Resuming stop watch which is not paused") );
42 if ( !--m_pauseCount
)
46 // get elapsed time since the last Start() in milliseconds
50 // returns the elapsed time since t0
51 long GetElapsedTime() const;
54 // the time of the last Start()
57 // the time of the last Pause() (only valid if m_pauseCount > 0)
60 // if > 0, the stop watch is paused, otherwise it is running
64 #endif // wxUSE_STOPWATCH
68 // Starts a global timer
69 // -- DEPRECATED: use wxStopWatch instead
70 void WXDLLEXPORT_BASE
wxStartTimer();
72 // Gets elapsed milliseconds since last wxStartTimer or wxGetElapsedTime
73 // -- DEPRECATED: use wxStopWatch instead
74 long WXDLLEXPORT_BASE
wxGetElapsedTime(bool resetTimer
= TRUE
);
76 #endif // wxUSE_LONGLONG
78 // ----------------------------------------------------------------------------
79 // global time functions
80 // ----------------------------------------------------------------------------
82 // Get number of seconds since local time 00:00:00 Jan 1st 1970.
83 extern long WXDLLEXPORT_BASE
wxGetLocalTime();
85 // Get number of seconds since GMT 00:00:00, Jan 1st 1970.
86 extern long WXDLLEXPORT_BASE
wxGetUTCTime();
89 // Get number of milliseconds since local time 00:00:00 Jan 1st 1970
90 extern wxLongLong WXDLLEXPORT_BASE
wxGetLocalTimeMillis();
91 #endif // wxUSE_LONGLONG
93 #define wxGetCurrentTime() wxGetLocalTime()
95 #endif // _WX_STOPWATCH_H_