3ds Max C++ API Reference
|
A basic timer tool. More...
#include <StopWatch.h>
Public Types | |
enum | TimerState { PLAYING =0 , PAUSED , STOPPED } |
Three timer states are defined. More... | |
Public Member Functions | |
UtilExport | StopWatch () |
Construct the StopWatch Object. More... | |
UtilExport void | Start () |
This method lets you start to trace the time and changes the current state to PLAYING. More... | |
UtilExport void | StartPaused () |
This method lets you start in a PAUSED state. More... | |
UtilExport void | Pause () |
This method lets you pause to trace the time and changes the current state to PAUSED. More... | |
UtilExport void | Resume () |
This method lets you resume to trace the time and changes the current state to PLAYING. More... | |
UtilExport void | Stop () |
This method lets you stop to trace the time and changes the current state to STOPPED. More... | |
UtilExport void | Reset () |
This method lets you clear the time traced and changes the current state to STOPPED. More... | |
UtilExport bool | IsRunning () const |
This method lets you know whether the timer is running. More... | |
UtilExport bool | IsPaused () const |
This method lets you know whether the timer is paused. More... | |
UtilExport bool | IsStopped () const |
This method lets you know whether the timer is stopped. More... | |
UtilExport TimerState | GetTimerCurrentState () const |
This method lets you know what the current timer state is. More... | |
UtilExport double | GetElapsedTime () const |
This method lets you get the elapsed time(milliseconds) traced. More... | |
UtilExport void | GetLocalTime (SYSTEMTIME *time) const |
Retrieves the current local time. More... | |
Static Public Member Functions | |
static UtilExport double | CalculateAverageOverhead (int loopCount) |
Calculates and returns the average overhead associated with Start/Stop and Pause/Resume. More... | |
![]() | |
static UtilExport void * | operator new (size_t size) |
Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More... | |
static UtilExport void * | operator new (size_t size, const std::nothrow_t &e) |
Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More... | |
static UtilExport void * | operator new (size_t size, const char *filename, int line) |
New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More... | |
static UtilExport void * | operator new (size_t size, int block_type, const char *filename, int line) |
New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More... | |
static UtilExport void * | operator new (size_t size, const std::nothrow_t &e, const char *filename, int line) |
New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More... | |
static UtilExport void * | operator new (size_t size, unsigned long flags) |
New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More... | |
static UtilExport void * | operator new (size_t size, const std::nothrow_t &e, unsigned long flags) |
New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More... | |
static UtilExport void * | operator new[] (size_t size) |
New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More... | |
static UtilExport void * | operator new[] (size_t size, const std::nothrow_t &e) |
New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More... | |
static UtilExport void * | operator new[] (size_t size, const char *filename, int line) |
New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More... | |
static UtilExport void * | operator new[] (size_t size, int block_type, const char *filename, int line) |
New operator used to allocate arrays of objects. More... | |
static UtilExport void * | operator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line) |
New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More... | |
static UtilExport void * | operator new[] (size_t size, unsigned long flags) |
New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More... | |
static UtilExport void * | operator new[] (size_t size, const std::nothrow_t &e, unsigned long flags) |
New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More... | |
static UtilExport void | operator delete (void *ptr) |
Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void | operator delete (void *ptr, const std::nothrow_t &e) |
Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More... | |
static UtilExport void | operator delete (void *ptr, const char *filename, int line) |
Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void | operator delete (void *ptr, int block_type, const char *filename, int line) |
Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void | operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line) |
Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More... | |
static UtilExport void | operator delete (void *ptr, unsigned long flags) |
Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void | operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags) |
Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More... | |
static UtilExport void | operator delete[] (void *ptr) |
Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void | operator delete[] (void *ptr, const std::nothrow_t &e) |
Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More... | |
static UtilExport void | operator delete[] (void *ptr, const char *filename, int line) |
Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void | operator delete[] (void *ptr, int block_type, const char *filename, int line) |
Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void | operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line) |
Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More... | |
static UtilExport void | operator delete[] (void *ptr, unsigned long flags) |
Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void | operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags) |
Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void * | operator new (size_t size, void *placement_ptr) |
Placement new operator. More... | |
static UtilExport void | operator delete (void *ptr, void *placement_ptr) |
Placement delete operator. More... | |
static UtilExport void * | aligned_malloc (size_t size, size_t alignment) |
Allocates memory on a specified alignment boundary. More... | |
static UtilExport void * | aligned_realloc (void *ptr, size_t size, size_t alignment) |
Reallocates memory on a specified alignment boundary. More... | |
static UtilExport void | aligned_free (void *ptr) |
Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More... | |
A basic timer tool.
A StopWatch is a light-weight timer tool that tests the time consumption.This timer tool uses high performance counter(QueryPerformanceCounter) to record the time comsumption and the time tested is at the milliseconds level.The workflow of StopWatch is like this: Start -> ( Pause ->(Resume)*n)*n -> Stop. Between Start and Stop, numbers of Pause -> (Resume)*n operations can be done. And also Stop operation can be done directly after Pause operation. For example:
enum TimerState |
Three timer states are defined.
UtilExport StopWatch | ( | ) |
UtilExport void Start | ( | ) |
This method lets you start to trace the time and changes the current state to PLAYING.
UtilExport void StartPaused | ( | ) |
This method lets you start in a PAUSED state.
UtilExport void Pause | ( | ) |
This method lets you pause to trace the time and changes the current state to PAUSED.
UtilExport void Resume | ( | ) |
This method lets you resume to trace the time and changes the current state to PLAYING.
UtilExport void Stop | ( | ) |
This method lets you stop to trace the time and changes the current state to STOPPED.
UtilExport void Reset | ( | ) |
This method lets you clear the time traced and changes the current state to STOPPED.
UtilExport bool IsRunning | ( | ) | const |
This method lets you know whether the timer is running.
UtilExport bool IsPaused | ( | ) | const |
This method lets you know whether the timer is paused.
UtilExport bool IsStopped | ( | ) | const |
This method lets you know whether the timer is stopped.
UtilExport TimerState GetTimerCurrentState | ( | ) | const |
This method lets you know what the current timer state is.
UtilExport double GetElapsedTime | ( | ) | const |
This method lets you get the elapsed time(milliseconds) traced.
Note that each paired call of Start/Stop and Resume/Pause imposes some overhead, mainly the time associated with 2 calls to QueryPerformanceCounter. If client code is making many Resume/Pause calls and/or the code executing between the Start/Stop and Resume/Pause calls runs very fast, the reported elapsed time may be significantly impacted by this overhead.
UtilExport void GetLocalTime | ( | SYSTEMTIME * | time | ) | const |
Retrieves the current local time.
|
static |
Calculates and returns the average overhead associated with Start/Stop and Pause/Resume.
Each paired call of Start/Stop and Resume/Pause imposes some overhead. The overhead is mainly the time associated with 2 calls to QueryPerformanceCounter. On average, the overhead is small (~ 1.6E-5 msec), but this can be significant if Pause/Resume is called many, many times while measuring something that runs very fast. The actual time associated with 2 calls to QueryPerformanceCounter is noisy, and it is not practical to correct for this overhead in the StopWatch code. Thus it is the responsibility of the client code to handle this if need be. Example:
loopCount | The number of loops calling Pause/Resume to average overhead over. |