1
我在尝试使用clock()
来确定C中函数的运行时间。 这是迄今为止代码:使用时钟确定函数的运行时间()
time_t start, end;
start = clock();
// Function here
end = clock();
printf("Time was: %lf\n", ((double)(end-start)/CLOCKS_PER_SEC));
并返回Time was: 0.030000
。如果我添加几秒钟的延迟,则会显示Time was: 0.500000
。我怎样才能让它在毫秒内正确显示?例如。 Time was: 500 milliseconds
或Time was: 30 milliseconds
?
谢谢!