MyTime.c
上传用户:cding2008
上传日期:2007-01-03
资源大小:1812k
文件大小:2k
- /////////////////////////////////////////////////////////////////////////////
- // MyTime.c : Defines the class behaviors for the application.
- //
- // ModelMagic 3D and 'glOOP' (OpenGL Object Oriented Programming library)
- // Copyright (c) Craig Fahrnbach 1997, 1999
- //
- // OpenGL is a registered trademark of Silicon Graphics
- //
- //
- // This program is provided for educational and personal use only and
- // is provided without guarantee or warrantee expressed or implied.
- //
- // Commercial use is strickly prohibited without written permission
- // from ImageWare Development.
- //
- /////////////////////////////////////////////////////////////////////////////
- #include <windows.h>
- #include <time.h>
- #include "MyTime.h"
- /////////////////////////////////////////////////////////////////////////////
- // Global variable Definitions:
- //
- LARGE_INTEGER Frequency; // performance counter frequency
- LARGE_INTEGER StartCount; // performance counter start count
- LARGE_INTEGER ElapsedCount; // performance counter end count
- clock_t ClockStart;
- BOOL MyTimeBegin()
- {
- // address of current counter value
- if(QueryPerformanceCounter(&StartCount))
- return TRUE;
- else
- // High frequency counter not available, use clock()
- ClockStart = clock();
- return TRUE;
- }
- double MyTimeElapsed()
- {
- _int64 iFrequency, iStart, iEnd;
- double dTime;
- // Get frequency of performance counter
- if(QueryPerformanceFrequency(&Frequency)) {
- // address of counter value
- QueryPerformanceCounter(&ElapsedCount);
- iFrequency = (Frequency.HighPart<<32)+Frequency.LowPart;
- iStart = (StartCount.HighPart<<32)+StartCount.LowPart;
- iEnd = (ElapsedCount.HighPart<<32)+ElapsedCount.LowPart;
- dTime = (double)(iEnd-iStart);
- dTime = dTime/iFrequency;
- }
- else
- {
- clock_t ClockElapse = clock();
- dTime = (double)(ClockElapse - ClockStart);
- dTime = dTime/CLOCKS_PER_SEC;
- }
- return dTime;
- }