|
|
| Keep It Simple, Stupid | |
| PerlMonks |
RE: How can I keep track of the execution time of a script?by Adam (Vicar) |
| on Oct 04, 2000 at 23:39 UTC ( #35320=note: print w/ replies, xml ) | Need Help?? |
|
$^T is the time that the script started. So end your script by returning time()-$^T. You might want to put this in the sig die handler: That prints the run time of your script in seconds. Update: By the way, there is a module called Benchmark that is great for testing algorithms and routines and such. Turnstep wrote a great tutorial on it called Benchmarking Your Code Update: For a variety of reasons, it is much better (and simpler too!) to use a single END block instead of the repition that I suggested. Thanks merlyn for pointing this out. (I also like the use of warn) Also, If your script is taking longer then a minute or two, you might want to break down those seconds to be minutes:seconds, but don't forget the more work you do after that last call to time, the less accurate the stamp. (Well, time only has a granularity of a second... so you actually have plenty of room, but anyway...)
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||