#include <stdio.h>
#include <time.h>
#include <sys/time.h>
int main() {
// 通用函数 time.h
time_t t ;
t = time(NULL) ;
printf("%d\n",(int)t) ;
sleep(2) ;
t = time(NULL) ;
printf("%d\n",(int)t) ;
// linux 时间毫秒级 sys/time.h
// struct timeval{
//long tv_sec; //秒
//long tv_usec; //微秒
//};
struct timeval start , end ;
gettimeofday(&start , NULL) ;
sleep(1) ;
gettimeofday(&end , NULL) ;
long timeuse = 1000000 * ( end.tv_sec - start.tv_sec ) + end.tv_usec - start.tv_usec;
printf("time pass = %ld us\n", timeuse) ;
return 0;
}