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$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxStopWatch
|
|
|
|
@wxheader{stopwatch.h}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05: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
|
|
|
|
wxStopWatch sw;
|
|
|
|
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-03-08 09:43:31 -05:00
|
|
|
Pauses the stop watch. Call Resume() to resume
|
2008-03-08 08:52:38 -05:00
|
|
|
time measuring again.
|
|
|
|
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-03-08 09:43:31 -05:00
|
|
|
Resumes the stop watch which had been paused with
|
2008-03-08 08:52:38 -05:00
|
|
|
Pause().
|
|
|
|
*/
|
|
|
|
void Resume();
|
|
|
|
|
|
|
|
/**
|
|
|
|
(Re)starts the stop watch with a given initial value.
|
|
|
|
*/
|
|
|
|
void Start(long milliseconds = 0);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the time in milliseconds since the start (or restart) or the last call
|
2008-03-08 09:43:31 -05:00
|
|
|
of
|
2008-03-08 08:52:38 -05:00
|
|
|
Pause().
|
|
|
|
*/
|
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
|
|
|
|
// ============================================================================
|
|
|
|
|
2008-03-25 03:36:12 -04:00
|
|
|
/** @ingroup group_funcmacro_time */
|
|
|
|
//@{
|
|
|
|
|
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
|
|
|
|