Applications in milliseconds and microseconds

Source: Internet
Author: User
Tags time in milliseconds
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 */
};

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.