On Saturday 05 Dec 2009 17:13:31 Parag Kalra wrote: > Hello All, > > I am looking for a simple way to determine the time taken by any Perl > script. > > A specific module to determine the time of execution will also do. > > After the Perl script gets executed, at the end it should print the time it > took to for the execution. > > So just like we execute SQL queries on MySQL and get the time in which the > results were fetched, I am looking for something similar in Perl. > > One simple approach would be to store the system at the start and again get > the time at the end. Subtract former from later. Do some calculations, > formatting and get the time of execution. > > But is there a simpler way than this? >
Well, on UNIXes you have the time command: http://en.wikipedia.org/wiki/Time_%28Unix%29 If you can't use it, then I would follow your approach. Note that you can encapsulate it into a module which you load using "use" or the "-M" flag at the beginning, so you can re-use it any time. See the so-called phasers like "BEGIN", "END", etc. Just make sure you use Time::HiRes, which is core: http://search.cpan.org/dist/Time-HiRes/ Regards, Shlomi Fish > Cheers, > Parag > -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ First stop for Perl beginners - http://perl-begin.org/ Bzr is slower than Subversion in combination with Sourceforge. ( By: http://dazjorz.com/ ) -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/