c++
1)GetTickCount()
1
2
3
4
5
6
7
8
9
10 |
#inlcude <windows.h><br>int main() { DWORD
start_time = GetTickCount(); { //code } DWORD
end_time = GetTickCount(); cout << "running times:"
<< end_time-start_time << "ms"
<< endl; return
0; } |
2)clocl()
#include <time.h> int main() { clock_t start_time = clock(); { //code } clock_t end_time = clock(); cout << "running time:" << static_cast<double>(end_time-start_time)/CLOCK_PER_SEC*1000 << "ms" << endl; return 0; }
原文:http://www.cnblogs.com/buptlyn/p/3652954.html