#define CLOCKS_PER_SEC = 1000000L; CLOCKS_PER_SEC:它用来表示一秒钟会有多少个时钟计时单元 (float)(end - start) / CLOCKS_PER_SEC : 表示秒 (float)(end - start) / CLOCKS_PER_SEC * 1000 :表示毫秒
#include <iostream>#include <time.h>using namespace std;int main(){char buffer[100000] = {0};clock_t start,end;//start timestart = clock();//to do...for(int i = 0; i < sizeof(buffer); i++){buffer[i] = i;}//end timeend = clock();printf("data: total time = %fms\n",(float)(end - start) / CLOCKS_PER_SEC * 1000);}