我正在尝试使用clock()
. 这是到目前为止的代码:
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
?
谢谢!