【发布时间】:2015-07-25 10:30:46
【问题描述】:
我想测量 insert_sort 函数的已用时间。但是,结果是 0.0000000 秒。我能做些什么?我尝试了其他时间库。不幸的是,它没有......谢谢。我又写了。
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
int number=1;
if(number == 1)
{
struct timeval start, end;
gettimeofday(&start, NULL);
for(int i=0; i<5;i++)
{
insertion_sort( kelime, n );
}
gettimeofday(&end, NULL);
printf("Elapsed time is %.10f",(end.tv_sec * 1000000 + end.tv_usec)- (start.tv_sec * 1000000 + start.tv_usec));
}
【问题讨论】:
-
查看
rdtsc内在函数。
标签: c function time execution measure