in reply to calculate the time taken to run a script

Take the time at the start and end of the program and subtract the first from the second.

You may want to look at Time::HiRes if you want sub-second accuracy.

--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

  • Comment on Re: calculate the time taken to run a script

Replies are listed 'Best First'.
Re^2: calculate the time taken to run a script
by Kanji (Parson) on Nov 23, 2005 at 16:56 UTC

    Perl already keeps track of start time for you in $^T, so unless you're doing something really funky, you can just subtract that from the current time to get elapsed time.

    END { my $elapsed_seconds = time - $^T; # Do something with $elapsed_seconds # e.g., print qq(<!-- Script took ${elapsed_seconds}s to run -->); }

        --k.