Sleep: Difference between revisions
Jump to navigation
Jump to search
→Approach1: sleep
| Line 79: | Line 79: | ||
# print current date & time | # print current date & time | ||
echo $(date '+%Y-%m-%d %H:%M:%S') | echo $(date '+%Y-%m-%d %H:%M:%S') | ||
</pre> | |||
Sleep couple [https://en.wikipedia.org/wiki/Microsecond microsecond]s<ref>[https://serverfault.com/questions/151109/how-do-i-get-the-current-unix-time-in-milliseconds-in-bash How do I get the current Unix time in milliseconds in Bash? - Server Fault]</ref>. Tested on {{Linux}} | |||
<pre> | |||
# print current unix timestamp e.g. 1598346362244 | |||
date +%s%N | |||
# sleep 1 millisecond = 0.001 seconds | |||
sleep 0.001s | |||
# print current unix timestamp | |||
date +%s%N | |||
</pre> | |||
Sleep couple microseconds. Tested on {{Mac}} | |||
<pre> | |||
# print current unix timestamp e.g. 1598346362244 | |||
php -r 'echo microtime(TRUE) . PHP_EOL;' | |||
# sleep 1 millisecond = 0.001 seconds | |||
sleep 0.001s | |||
# print current unix timestamp | |||
php -r 'echo microtime(TRUE) . PHP_EOL;' | |||
</pre> | </pre> | ||