⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timer.cpp

📁 有关程序计时方法的介绍
💻 CPP
字号:
#include <windows.h>
#include <stdio.h>

class Timer
{
	
	__int64 m_nFrequency;
	__int64 m_nStartCount;
public:
	Timer()
	{
		QueryPerformanceFrequency((LARGE_INTEGER*)&m_nFrequency);
		Reset();
	}
	void Reset()
	{
		QueryPerformanceCounter((LARGE_INTEGER*)&m_nStartCount);
	}
	void Report()
	{
		__int64 nCurrentCount;
		QueryPerformanceCounter((LARGE_INTEGER*)&nCurrentCount);
		double t = double(nCurrentCount - m_nStartCount) / m_nFrequency * 1000 * 1000;
		printf("Used Time = ");
		if(t <= 800)
			printf("%.2lf ns\n", t);
		else if(t <= 800 * 1000)
			printf("%.2lf ms\n", t / 1000.0);
		else
			printf("%.2lf s\n", t / 1000.0 / 1000.0);
	}
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -