[TriLUG] What's an effective method for timing a perl script

erik at underhanded.org erik at underhanded.org
Fri Apr 15 15:11:12 EDT 2005


On Fri, Apr 15, 2005 at 02:47:26PM -0400, Matt Frye wrote:

> ...and so on and let's say it deletes a billion files.  What's an
> effective way of timing the whole thing?  This needs to be
> ultra-portable so not using any modules is a plus.  I started with...
> 
> ($exectime) = times; 
> 
> ...but I'm not sure that's giving me what I need.  I tested up to 7500
> files and ne'er more than .01 so I want to make sure I'm getting real
> data.

Easiest way is like so:

my $startTime = time;
while(glob('./*/Recent/*')){unlink $_}
print time - $startTime,"\n";

You may want to look into Time::HiRes if you need greater accuracy then
seconds.

-- 
ICQ: 116080581 | Jabber: azhrarn at underhanded.org
AIM/Y!: AzhrarnLOD | IRC: Azhrarn @ irc.chatspike.net
( Vim, Tabs, BSD Braces, Debian, and Perl )
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://www.trilug.org/pipermail/trilug/attachments/20050415/48d0f578/attachment.pgp>


More information about the TriLUG mailing list