Win32控制台测试程序如下, 其中完整的程序代码下载是: http://download.csdn.net/detail/hemmingway/4600235
// Test_Time.cpp : 定义控制台应用程序的入口点。
//#include "stdafx.h"
#include "Timer.h"
#include "TimeCounter.h"#define N 10000#define TEST_PRO \for(int i = 0; i < N; ++i) \{ \for (int j= 0; j < N; ++j) \{} \} \printf("loop ok...\n\n") \#define TIME_START CTimeCounter* pT = new CTimeCounter()
#define TIME_END ShowTime(pT->GetExecutionTime())//
// Show execution time (ms)
void ShowTime(int64_t nTime)
{printf("Total time: %I64d millisecond\n\n",nTime); //在g++中对应的是<stdint.h> int64_t, 应该用%lld输出
}int _tmain(int argc, _TCHAR* argv[])
{CTimer time;printf("1. CTimer\n\n");time.start("CTimer");TEST_PRO;time.plot();getchar();printf("2. CTimeCounter\n\n");TIME_START;TEST_PRO;TIME_END;getchar();return 0;
}