2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: stopwatch.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxStopWatch
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxStopWatch
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-10-07 12:57:34 -04:00
|
|
|
The wxStopWatch class allow you to measure time intervals.
|
|
|
|
|
|
|
|
For example, you may use it to measure the time elapsed by some function:
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@code
|
2008-10-07 12:57:34 -04:00
|
|
|
wxStopWatch sw;
|
2008-03-08 08:52:38 -05:00
|
|
|
CallLongRunningFunction();
|
|
|
|
wxLogMessage("The long running function took %ldms to execute",
|
|
|
|
sw.Time());
|
|
|
|
sw.Pause();
|
|
|
|
... stopwatch is stopped now ...
|
|
|
|
sw.Resume();
|
|
|
|
CallLongRunningFunction();
|
|
|
|
wxLogMessage("And calling it twice took $ldms in all", sw.Time());
|
|
|
|
@endcode
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxbase}
|
|
|
|
@category{misc}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxTimer
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
class wxStopWatch
|
2008-03-08 08:52:38 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructor. This starts the stop watch.
|
|
|
|
*/
|
|
|
|
wxStopWatch();
|
|
|
|
|
|
|
|
/**
|
2008-10-07 12:57:34 -04:00
|
|
|
Pauses the stop watch. Call Resume() to resume time measuring again.
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
If this method is called several times, @c Resume() must be called the same
|
2008-03-08 09:43:31 -05:00
|
|
|
number of times to really resume the stop watch. You may, however, call
|
2008-03-08 08:52:38 -05:00
|
|
|
Start() to resume it unconditionally.
|
|
|
|
*/
|
|
|
|
void Pause();
|
|
|
|
|
|
|
|
/**
|
2008-10-07 12:57:34 -04:00
|
|
|
Resumes the stop watch which had been paused with Pause().
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void Resume();
|
|
|
|
|
|
|
|
/**
|
|
|
|
(Re)starts the stop watch with a given initial value.
|
|
|
|
*/
|
|
|
|
void Start(long milliseconds = 0);
|
|
|
|
|
|
|
|
/**
|
2008-10-07 12:57:34 -04:00
|
|
|
Returns the time in milliseconds since the start (or restart) or the last
|
|
|
|
call of Pause().
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
long Time() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
// ============================================================================
|
|
|
|
// Global functions/macros
|
|
|
|
// ============================================================================
|
|
|
|
|
2009-01-05 15:48:06 -05:00
|
|
|
/** @addtogroup group_funcmacro_time */
|
2008-03-25 03:36:12 -04:00
|
|
|
//@{
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Returns the number of seconds since local time 00:00:00 Jan 1st 1970.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-25 03:36:12 -04:00
|
|
|
@see wxDateTime::Now()
|
|
|
|
|
|
|
|
@header{wx/stopwatch.h}
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
long wxGetLocalTime();
|
|
|
|
|
|
|
|
/**
|
2008-03-25 03:36:12 -04:00
|
|
|
Returns the number of milliseconds since local time 00:00:00 Jan 1st 1970.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-25 03:36:12 -04:00
|
|
|
@see wxDateTime::Now(), wxLongLong
|
|
|
|
|
|
|
|
@header{wx/stopwatch.h}
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-25 03:36:12 -04:00
|
|
|
wxLongLong wxGetLocalTimeMillis();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-25 03:36:12 -04:00
|
|
|
Returns the number of seconds since GMT 00:00:00 Jan 1st 1970.
|
|
|
|
|
|
|
|
@see wxDateTime::Now()
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-25 03:36:12 -04:00
|
|
|
@header{wx/stopwatch.h}
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-25 03:36:12 -04:00
|
|
|
long wxGetUTCTime();
|
|
|
|
|
|
|
|
//@}
|
2008-03-08 08:52:38 -05:00
|
|
|
|