Reprinted statement: This blog Article Allow free reprint, but reprint need to indicate the author, source: Denny wqf363@hotmail.com Source: www.huntmine.com a) time unit seconds (second), milliseconds (MS), microseconds (μs ), nanoseconds (NS), which are 1000 hexadecimal. 1 second = 1000000000 nanoseconds (one second in 1 billion)
1 second = 1000000 microseconds (one second per million)
1 second = 1000 milliseconds (1‰ seconds) ii) void sleepinms (unsigned int a_sleeptime) of sleep in milliseconds)
{
Struct timeval l_ TV;
L_ TV. TV _sec = a_sleeptime/1000;
L_ TV. TV _usec = a_sleeptime % 1000*1000;
Select (0, null, & l_ TV );
} 3) obtain the current time in milliseconds, and in microseconds unsigned long getus ();
Unsigned long getms (); unsigned long getus ()
{
Struct timeval l_ TV;
Gettimeofday (& l_ TV, null );
Unsigned long l_ret = 0;
Rochelle ret = (Rochelle TV. TV _sec & 0 xffffffff) * 1000000;
Rochelle RET + = maid;
Return l_ret;
} Unsigned long getms ()
{
Struct timeval l_ TV;
Gettimeofday (& l_ TV, null );
Unsigned long l_ret = 0;
Rochelle ret = (Rochelle TV. TV _sec & 0 xffffffff) * 1000;
Rochelle RET + = (Rochelle TV. TV _usec/1000 );
Return l_ret;
}
4) Some Time structures struct timeval {
Time_t TV _sec;/* seconds */
Suseconds_t TV _usec;/* microseconds */
}; Struct timezone {
Int tz_minuteswest;/* minutes w of Greenwich */
Int tz_dsttime;/* type of DST correction */
};