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;
}

posted on 2019-07-22 15:39  荷楠仁  阅读(154)  评论(0编辑  收藏  举报

导航