Usleep-time delay in microseconds

Source: Internet
Author: User
Tags sleep usleep
 Description of Use

The Usleep command is used to delay the time in microseconds (sleep some number of microseconds), which actually does not reach this precision (Probably not accurate on many machines the mic  Rosecond. Count on precision only to-4 or maybe-5.). If there is no usleep command in the system, you can use the Sleep command, and the Sleep command can specify a time delay with a decimal. 1 seconds =1000 milliseconds =1000,000 microseconds =1000,000,000 nanoseconds. Common Ways

Format: Usleep <us>

Latency <us> microseconds.

using the example Example one usleep command accuracy test

[Root@jfht ~]# date +%s.%n; Usleep Date +%s.%n
04.194798315
04.199352948
[Root@jfht ~]# date +%s.%n; Usleep Date +%s.%n
12.684509970
12.688986355
[Root@jfht ~]# date +%s.%n; Usleep 1000; Date +%s.%n
33.179766926
33.186719087
[Root@jfht ~]# date +%s.%n; Usleep 10000; Date +%s.%n
45.556317402
45.571467950
[Root@jfht ~]# date +%s.%n; Usleep 100000; Date +%s.%n
59.656176597
59.761001631
[Root@jfht ~]# date +%s.%n; Usleep 1000000; Date +%s.%n
56.700405298
57.704304279
[Root@jfht ~]#

Example two sleep command accuracy test

[Root@jfht ~]# date +%s.%n; Sleep 1; Date +%s.%n
47.111204217
48.115898894
[Root@jfht ~]# date +%s.%n; Sleep 0.1; Date +%s.%n
57.760602228
57.865456080
[Root@jfht ~]# date +%s.%n; Sleep 0.01; Date +%s.%n
08.912279911
08.927840798
[Root@jfht ~]# date +%s.%n; Sleep 0.001; Date +%s.%n
18.171663617
18.176771668
[Root@jfht ~]# date +%s.%n; Sleep 0.0001; Date +%s.%n
27.290651737
27.295785240
[Root@jfht ~]#

Problem Thinking Related Information

"1" nixway.net usleep (1) Command reference
http://www.nixway.net/index.php?manitem&mid=2558
"2" linuxsir.org Ubuntu usleep command is not available, which package to pack it.
http://www.linuxsir.org/bbs/showthread.php?t=315109


http://codingstandards.iteye.com/blog/1007783

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.