ARTS-S c语言统计程序运行时间
#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;
}