Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: How to sleep 1 microsecond?

by tobyink (Abbot)
on Aug 17, 2012 at 16:36 UTC ( #988023=note: print w/ replies, xml ) Need Help??

in reply to How to sleep 1 microsecond?

use Time::HiRes qw(time); my $until = time + 0.00_001; 1 while time < $until;
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Comment on Re: How to sleep 1 microsecond?
Download Code
Replies are listed 'Best First'.
Re^2: How to sleep 1 microsecond?
by sophate (Beadle) on Aug 18, 2012 at 10:42 UTC

    Thanks. This works pretty well :-) But just wondering why the smallest unit for time() is 0.00_001 but not 0.000_001?

      Meh, did I only do a one-hundred-thousandth of a second? Always getting my decimal places mixed up! Use whatever fraction of a second you like, but be aware of the limits of floating point numbers.

      perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://988023]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (13)
As of 2015-11-30 15:47 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (774 votes), past polls