On 3/31/06, John W. Krahn <[EMAIL PROTECTED]> wrote: > Mr. Shawn H. Corey wrote: > > On Fri, 2006-31-03 at 14:41 -0700, Bryan Harris wrote: > >>I have a script that takes ~5 seconds to run, but I'd like to get it down to > >><1 sec. My problem is I don't know which part is the slow part. So given > >>something like this: > >> > >>************************************** > >>#! /usr/bin/perl -w > >> > > > > my $start_time = time; > > Or you could just use Perl's built-in $^T variable. >
[snip] That all depends what you're trying to do. $^T is initialized as soon as the script starts, and unless you establish some sort of baseline, the startup time will be added to your first chunk of code and skew the results. On my system, for instance: #!/usr/bin/perl use warnings; use strict; print time - $^T; Prints anywhere from 2-8. That's a significant portion of the total time for a short script. Hopefully OP has a better machine, but he'll still want to check that startup time, both because it'll be interesting its own right, and because he'll want to subtract it out if he uses $^T to benchmark his code. I'd also recommend OP take a look at Time::HiRes. Shaving fractions of seconds off blocks of code is going to be difficult to with a timer that only has a resolution of a second. -- jay -------------------------------------------------- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org values of β will give rise to dom!