【发布时间】:2013-02-06 06:35:38
【问题描述】:
我正在用 c 编写一些基本的东西,计算执行 shell 脚本所需的时间。
我有
gettimeofday(&start, NULL);
// code here
gettimeofday(&end, NULL);
// print end - start
我知道 timeval 结构有 tv_sec 和 tv_usec ,但即使对于诸如“sleep 3”之类的脚本,我仍然得到 0 结束 - 开始差异。任何猜测为什么?
【问题讨论】: