Stuart Clemons wrote:
>
> Hi all:
Hello,
> I'm trying to determine how long an system operation takes. Anyone know
> of a simple way to do this ?
Certainly. :-)
> I wanted to establish the start time. Then run the operation. Then mark
> the finish time. Then substract the start time from the finish time to
> get an elapsed time. Here's the simplistic approach I tried. I'm sure I
> need a time that is measured in seconds or something like that, but I'm
> not sure how to do this.
Hint:
perldoc -f time
> Here's what I tried:
>
> #!/usr/bin/perl -w
> use warnings;
> use strict;
>
> my $start = "Tue Jan 27 15:40:16 2004";
> print "This is the start time: $start \n";
my $start = time;
print 'This is the start time: ', scalar localtime $start, "\n";
> system (This is where the system process stuff goes);
>
> my $finish = localtime;
> print "This is the finish time: $finish \n";
my $finish = time;
print 'This is the finish time: ', scalar localtime $finish, "\n";
> my $elapsedtime = ("$finish" - "$start") ;
> print "This is the time diff: $elapsedtime \n";
my $elapsedtime = $finish - $start;
print "This is the time diff in seconds: $elapsedtime\n";
If you need microseconds instead of seconds look at the Time::HiRes
module.
perldoc Time::HiRes
Also have a look at the Benchmark module.
perldoc Benchmark
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>