Re: Perl make depend made faster

Keith Owens (kaos@audio.apana.org.au)
Sun, 15 Sep 1996 01:04:22 +1000 (EST)


On my 486 DX2/66 SCSI-2 with 20 Mb, depend.awk took 3:34 wall clock (best
time), depend.pl took 2:30 (worst time). A couple of tweaks to depend.pl
knocked that down even more, to 2:07.

Doing "undef $/;" and replacing "$program = join '', <FILE>' with "$program =
<FILE>;" took 20 seconds off the wall clock. Removing all "my" keywords took
out another second or so.

Unfortunately the technique "foreach $file (@ARGV); ... push(@ARGV,$rfname);"
does not work. The "foreach" list is evaluated once, new files are pushed
onto @ARGV but never actually processed (perl 5.001m). This results in
missing dependencies in /drivers/sbus/char/.depend.

Speed up patch and correction to ARGV list follow.

--- depend.pl.orig Sun Sep 15 00:58:43 1996
+++ depend.pl Sun Sep 15 00:37:18 1996
@@ -19,19 +19,24 @@
my @parray = split( ' ' , $ENV{"HPATH"} );
grep ( do { s/^I//; s/[\/\s]*$/\//; } && 0 , @parray );

+# swallow entire files at a single gulp
+
+undef $/;
+

# Iterate on input files


-foreach $file ( @ARGV ) {
+for ($i = 0; $i <= $#ARGV; ++$i) {
+ $file = $ARGV[$i];


# Sensible if boring initializations ..


- my $hasdep = 0, $hasconfig = 0, $needsconfig = 0;
- my $cmd = '', $depname = '', $relpath = '';
- my @includes = ();
+ $hasdep = 0, $hasconfig = 0, $needsconfig = 0;
+ $cmd = '', $depname = '', $relpath = '';
+ @includes = ();


# Massage filename into $depname, $relpath, $cmd
@@ -52,7 +57,7 @@


open ( FILE, $file ) or die "Can't open $file: $!\n";
- $program = join '', <FILE>;
+ $program = <FILE>;
close FILE;