开发者

gettimeofday - explanation of the exact struct timeval fields' meaning

I'm trying to write a simple function in C that would calculate the difference between two moments in nanoseconds. To do this, I thought of using the function gettimeofday, which updates the given struct timeval's fields.

As the man page said, the struct timeval's fields are:

time_t      tv_sec;     /* seconds */  
suseconds_t tv_usec;    /* microseconds */  

My question is as follows:

Is the tv_usec field is the WHOLE TIME passed since the EPOCH in microseconds, or is it just the remain of开发者_如何学JAVA the time in microseconds?

For example, if the time passed is 100 seconds and 25 microseconds, will the tv_usec field have the value '25' or the value '100000025'?

Thanks a lot.


It's the remainder.

This is the rest of the elapsed time (a fraction of a second), represented as the number of microseconds. It is always less than one million.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜