【发布时间】:2012-01-29 22:05:52
【问题描述】:
我想减去两个 gettimeofday 实例,并以毫秒为单位给出答案。
想法是:
static struct timeval tv;
gettimeofday(&tv, NULL);
static struct timeval tv2;
gettimeofday(&tv2, NULL);
static struct timeval tv3=tv2-tv;
然后将 'tv3' 转换为毫秒分辨率。
【问题讨论】:
-
你自己搞不定? : 逐个字段相减,如果
tv_usec为负数,则归一化结果! -
我认为有更好的方法,而不是使用 'if' 语句。
标签: c++ linux gettimeofday