|
-
May 14th, 1999, 09:00 PM
#1
timegettime
Can someone help me figure out how to use TimeGetTime(); ?? Please.
-
May 14th, 1999, 10:05 PM
#2
Re: timegettime
You can use timeGetTime to get the duration between execution points as follows.
DWORD start = timeGetTime();
...... Do Some Job ......
DWORD end = timeGetTime();
DWORD ellapsed = end - start; // in milisecond unit
-
May 17th, 1999, 02:16 PM
#3
Re: timegettime
// CStopWatch.h
//
#ifndef CSTOPWATCH_H
#define CSTOPWATCH_H
#include <windows.h>
#include <mmsystem.h>
//////////////////////////////////////////////////////////////////////////////
// CStopWatch
class CStopWatch
{
public:
//
// construction/destruction
//
CStopWatch();
CStopWatch(int resolution);
//
// operators
//
void Start(); // start stopwatch
float Stop(); // stop stopwatch, return = number of seconds
private:
int Resolution; // set timer resolution in milliseconds (only effective on WinNT)
int StartTime; // start time
};
#endif // !#define CSTOPWATCH_H
// CStopWatch.cpp
//
#include "stdafx.h"
#include "CStopWatch.h"
#if _MSC_VER >= 1000
//
// include the multimedia library for linking
//
#pragma comment( lib, "winmm" )
#pragma once
#endif // _MSC_VER >= 1000
CStopWatch :: CStopWatch()
{
Resolution = 1;
StartTime = 0;
}
CStopWatch :: CStopWatch(int res)
{
Resolution = res;
StartTime = 0;
}
void CStopWatch :: Start()
{
#ifdef _WIN32
StartTime = timeBeginPeriod(Resolution);
if (StartTime != 0) throw(0,"Unable to set requested resolution","CStopWatch");
StartTime = timeGetTime();
#endif
}
float CStopWatch :: Stop()
{
float RT = 0.0;
#ifdef _WIN32
RT = (timeGetTime() - StartTime)/1000.0F;
StartTime = timeEndPeriod(Resolution);
#endif
return RT;
}
-
May 20th, 1999, 03:45 AM
#4
Re: timegettime
Add winmm.lib to linker settings if necessary
,,,^..^,,,
Michel
-
May 21st, 1999, 09:06 PM
#5
Re: timegettime
Note I would like this to work under MFC if at all possible. I would like it to function as a timer for a simple 2D animation. (I need more help understanding)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|