嵌入式平台C语言 耗时统计
头文件#include <time.h>struct timeval start, end;gettimeofday(&start, NULL);/** tocalculate code*/gettimeofday(&end, NULL);long long total_time = (end.tv_sec - start.tv_sec) * 1000000 + (en
·
头文件#include <time.h>
struct timeval start, end;
gettimeofday(&start, NULL);
/*
* to calculate code
*/
gettimeofday(&end, NULL);
long long total_time = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec);
// get the run time by microsecond
printf("total time is %lld us\n", total_time);
// get the run time by millisecond
total_time /= 1000;
printf("total time is %lld ms\n", total_time)
更多推荐
所有评论(0)