Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to read milliseconds with perl

Status
Not open for further replies.

clarissa1996

Technical User
Jan 31, 2002
78
CH
I need to calculate the elapsed time between two functions, in a perl program.

With the function localtime() I can read the current time. But the smaller unit is only seconds !

Is it possible to read a smaller time unit (for example milliseconds) ?


TIA Michelangelo Rezzonico
 
Here's a demo of Time::HiRes
________________________________________________________________________________
use Time::HiRes;

$ts= [Time::HiRes::gettimeofday];

$tp = Time::HiRes::tv_interval($ts, [Time::HiRes::gettimeofday]);
sleep(1);
$td = Time::HiRes::tv_interval($ts, [Time::HiRes::gettimeofday]);

print $tp, " ", ($td - $tp), " \r";

Mike
"Experience is the comb that Nature gives us after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
ive seen somewhere a nanoseconds calculator function
sorry dont remeber where
search from google "nanoseconds perl calcul"

this was just a comment
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top