php has a feature like microtime. Also his add. implementation as getmicrotime (); In perl I found only times, and then it always produces 4 zeros.

 function getmicrotime() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } 
  • @ nörbörnën share a piece of code pliz)) - Radzhab 1:16 pm
  • I don’t understand how to make a piece of code divorced from the context, most likely you will need Time::HiRes::time - nörbörnën 1:27 pm

1 answer 1

gettimeofday ()

In the context of an array, it returns a two-element array with seconds and microseconds since the beginning of the epoch. In scalar context, returns seconds (floating point) as Time :: HiRes :: time ()

tv_interval ($ ref_to_gettimeofday [, $ ref_to_later_gettimeofday])

Returns seconds seconds (float) between two values ​​that should have been returned by gettimeofday (). If the second argument is omitted, the current time is used. documentation

 use Time::HiRes qw(gettimeofday tv_interval); my $startTime = [ gettimeofday ]; # some actions my $endTime = [ gettimeofday ]; my $elapsed = tv_interval($startTime,$endTime); print "TIME: $elapsed\n";