• c++ 计时


    //z 2014-06-19 17:18:49 L.195'24071 BG57IV3@XCL T1202481319.K.F636940351 [T22,L436,R14,V351]
    c++ timer 计时
    //z 2014-06-19 17:18:49 L.195'24071 BG57IV3@XCL T1202481319.K.F636940351 [T22,L436,R14,V351]
    //z 2014-06-20 14:28:39 L.194'34281 BG57IV3@XCL T816588223 .K.F1994950968[T65,L612,R42,V717]

    class ZTimer
    {
    public:
    	ZTimer()//z is2120@BG57IV3
    	{
    		Init();
    	}
    
    	explicit ZTimer(const char* desc)
    	{
    		Init();
    		if (desc != NULL)
    		{
    			strcpy_s(_desc, desc);
    		}
    	}
    
    	void Reset()
    	{
    		++_resetCnt;
    		QueryPerformanceCounter(&_startCount);
    	}
    
    	double Elapsed()
    	{
    		return Elapsed(NULL);
    	}
    
    	double Elapsed(char* subDesc)
    	{
    		QueryPerformanceCounter(&_endCount);
    		double fElapsedTime = (_endCount.QuadPart - _startCount.QuadPart) * 1000.0 / _frequency.QuadPart;
    		char cBuff[256] = { 0 };
    		if (subDesc == NULL)
    		{
    			sprintf_s(cBuff, "Elapsed %s.T#%-2d.R#%-2d: %.3f", _desc, _cnt++, _resetCnt, fElapsedTime);
    		}
    		else
    		{
    			sprintf_s(cBuff, "Elapsed %s.%s T#%-2d.R#%-2d: %.3f", _desc,subDesc, _cnt++, _resetCnt, fElapsedTime);
    		}
    		
    		OutputDebugStringA(cBuff);
    
    		return fElapsedTime;
    	}
    
    	~ZTimer()
    	{
    		Elapsed();
    	}
    
    private:
    	void Init()
    	{
    		memset(_desc, 0, sizeof(_desc));
    		_startCount.QuadPart = 0;
    		_endCount.QuadPart = 0;
    		_cnt = 0;
    		_resetCnt = 0;
    		QueryPerformanceFrequency(&_frequency);
    		QueryPerformanceCounter(&_startCount);
    	}
    
    private:
    	LARGE_INTEGER _frequency;
    	LARGE_INTEGER _startCount;
    	LARGE_INTEGER _endCount;
    	char _desc[64];
    	int _cnt;
    	int _resetCnt;
    };

    //z 2014-06-20 14:28:39 L.194'34281 BG57IV3@XCL T816588223 .K.F1994950968[T65,L612,R42,V717]


    @IS2120#CNBLOGS.T2169364049[T1,L65,R1,V259]:备忘
    $ € ₤ ₭ ₪ ₩ ₮ ₦ ₱ ฿ ₡ ₫ ﷼ ¥ ﷼ ₫ ₡ ฿ ₱ ₦ ₮ ₩ ₪ ₭ ₤ € $
  • 相关阅读:
    ExtJs控件属性配置详细
    static void和void区别(转)
    OpenSSL 内存管理分析笔记
    Openssl 之大数运算函数 BN
    python学习:字符串
    python学习:字典
    python学习:购物车程序
    python学习:元组和嵌套
    python学习:列表
    python学习:continue及break使用
  • 原文地址:https://www.cnblogs.com/IS2120/p/6745651.html
Copyright © 2020-2023  润新知