欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

精确的计时类

程序员文章站 2024-01-24 08:55:28
...
class MyTimeCount
{
public:
	MyTimeCount()
	{
		QueryPerformanceFrequency(&fr);
	}
	~MyTimeCount()
	{

	}
	void Start()
	{
		QueryPerformanceCounter(&bg);
		ed = bg;
		fTime = 0.0f;
	}
	float Stop()
	{
		QueryPerformanceCounter(&ed);

		fTime = 1000.0f*(ed.QuadPart-bg.QuadPart)/fr.QuadPart;
		return fTime;
	}
	float GetTime()
	{
		return fTime;
	}
private:
	LARGE_INTEGER	bg;
	LARGE_INTEGER	ed;
	LARGE_INTEGER	fr;
	float			fTime;

};

版权声明:本文博主原创文章,博客,未经同意不得转载。