#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
int main() {
struct timeval start, end;
gettimeofday(&start, NULL);
sleep(2);
gettimeofday(&end, NULL);
long seconds = end.tv_sec - start.tv_sec;
long micros = end.tv_usec - start.tv_usec;
printf("Time elpased is %f s.\n", ((float)micros) / 1000000 + seconds);
return 0;
}
ARTS-S c language program run time statistics
Guess you like
Origin www.cnblogs.com/zhouyang209117/p/11226244.html
Recommended
Ranking