#include "stdafx.h" #include <iostream> #include <ctime> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { clock_t start, finish; start = clock(); int i = 0; while( i != 100000000){ i ++; } double total_time; finish = clock(); total_time = (double)(finish - start) / CLOCKS_PER_SEC; cout<<"total time is "<<total_time<<" 秒"<<endl; return 0; } 上面是例子,主要调用ctime库,运行在VS2005