Alejandro Santillan wrote:
> I would like to know if there exists some module that is able con add and
> substract times.
>
> For example, I want to see the time in seconds between the beginning and
> ending of an application.
> Something like this:
>
> $a="13:12:01";
> $b="13:02:01";
>
> $c=$a-$b;
>
> I would like $c to be 00:10:00, or 600 secs. Is some module able to do this
> task?
Here's like 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;
__END__
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs