C里面的定时器
直接上代码
#include <iostream>
#include <cstring>
#include <string.h>
#include <stdlib.h>
#include <time.h>
void main
{
clock_t start,finish;
start = clock();
for(int jj=0;jj<6000;jj++)
for(int jk=0;jk<6000;jk++);
finish = clock();
printf("%ld, %ld\n", start, finish);
printf("%f\n", ((double)finish - (double)start) / CLOCKS_PER_SEC);
}
要包含#include <time.h>
CLOCKS_PER_SEC在time.h内宏定义为1000,的意思是每过1/CLOCKS_PER_SEC秒,调用clock()返回值加1.