换一个名字
time是库函数
#include <stdio.h>
#include <time.h>
int main(int argc, char** argv) {
clock_t start_cnt, end_cnt;
start_cnt = clock();
// ...
end_cnt = clock();
double t = (end_cnt - start_cnt) / CLOCKS_PER_SEC;
printf("Use time: %f s. \n", t); // 单位为秒
return 0;
}
CLOCKS_PER_SEC为每秒的计时周期数,一般CLOCKS_PER_SEC的值为1000000,即以us为单位。