Wednesday, February 24, 2010

is it possible to get a more accurate time

is it possible to get a more accurate time?

edit 1:
I found another peace of code that does it

$start = (time)[0];

# script code goes here

$end = (time)[0];
printf "Elapsed time: %.2f seconds!\n", $end - $start;


edit 2:

Got another one.... this one shows something like "Elapsed time: 1.149333 seconds!"

use Time::HiRes;
my $start = [ Time::HiRes::gettimeofday( ) ];

## Your code goes here

my $elapsed = Time::HiRes::tv_interval( $start );
print "Elapsed time: $elapsed seconds!\n";

No comments: