首页 > 代码库 > 精准的计时类

精准的计时类

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;

};

精准的计时类