[EMAIL PROTECTED] wrote:
>
> How can i get the time down to miliseconds with perl? I have a logfile,
> with various inputs per second, so i'd like to be able to see how many
> miliseconds between them.
>
> Any sugestions?
If you just want time to msecs, try Time::HiRes::gettimeofday
If you need to time an interval, here are 4 ways:
my $pt0 = Win32::GetTickCount ();
sleep 1; # your code to time here
printf "%.3f seconds\n", (Win32::GetTickCount () - $pt0) / 1000;
use Time::HiRes qw(gettimeofday tv_interval);
my $pt1 = [gettimeofday ()];
sleep 1; # your code to time here
printf "%.3f seconds\n", tv_interval ($pt1);
use POSIX;
my $pt2 = clock ();
sleep 1; # your code to time here
printf "%.3f seconds\n", (clock () - $pt2) / 1000;
use Win32::API;
my $GetTickCount = new Win32::API('kernel32', 'GetTickCount', '', 'N');
my $pt3 = $GetTickCount->Call();
sleep 1; # your code to time here
printf "%.3f seconds\n", ($GetTickCount->Call () - $pt3) / 1000;
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs