Perl高精度计时器

use strict ;

use Time::HiRes qw(gettimeofday) ;

sub Test
{
# sec: seconds
# usec: microsecond

my ($start_sec, $start_usec) = gettimeofday() ;

#======================#
# Place your code here!#
#======================#


my ($end_sec, $end_usec) = gettimeofday() ;

# Compute time elipsed
my $timeDelta = ($end_usec - $start_usec) / 1000 + ($end_sec - $start_sec) * 1000;
print $timeDelta ;
}

&Test() ;

1 ;

posted on 2011-07-27 17:33  perlman  阅读(1606)  评论(0编辑  收藏  举报

导航