On Mon Jan 09 17:05:30 2006, [EMAIL PROTECTED] wrote:
> Simple profile suggests that pmc2c.pl is spending about 25% of it's
> total execution time loading FindBin.  The lib path use of FindBin::Bin
> can be replaced with 'use lib qw( . lib ../lib ../../lib );' while the
> other uses of FindBin::Bin will have be replaced by values that are
> interpolated by genfile().
> 

Perhaps things have changed since January 2006, when this ticket was
opened.  My own profiling on individual runs of tools/build/pmc2c.pl
suggested that FindBin was only taking up between 1.8% and 6.5% of total
execution time.  Be that as it may, ...

This patch gets us a little way toward that goal by determining
$FindBin::Bin once during tools/build/pmc2c.pl and then passing it as an
argument to the Parrot::Pmc2c::Pmc2cMain constructor, thereby
eliminating some $Bin lookups in that method.  My timing suggests that
this reduces total time for 'make' by 1.5%.

Please review.  I'll apply next week if there is no objection.

Thank you very much.
kid51
Index: tools/build/pmc2c.pl
===================================================================
--- tools/build/pmc2c.pl        (revision 26514)
+++ tools/build/pmc2c.pl        (working copy)
@@ -4,9 +4,9 @@
 
 use strict;
 use warnings;
-use FindBin;
-use lib "$FindBin::Bin/../..";
-use lib "$FindBin::Bin/../../lib";
+use FindBin qw($Bin);
+use lib "$Bin/../..";
+use lib "$Bin/../../lib";
 use Getopt::Long ();
 use Parrot::Pmc2c::Pmc2cMain ();
 
@@ -39,11 +39,12 @@
         include => [EMAIL PROTECTED],
         opt     => \%options,
         args    => [EMAIL PROTECTED],
+        bin     => $Bin,
     }
 );
 
 if ( $action{default} ) {
-    $self->dump_vtable("$FindBin::Bin/../../src/vtable.tbl");
+    $self->dump_vtable("$Bin/../../src/vtable.tbl");
     exit;
 }
 
Index: lib/Parrot/Pmc2c/Pmc2cMain.pm
===================================================================
--- lib/Parrot/Pmc2c/Pmc2cMain.pm       (revision 26514)
+++ lib/Parrot/Pmc2c/Pmc2cMain.pm       (working copy)
@@ -3,7 +3,6 @@
 package Parrot::Pmc2c::Pmc2cMain;
 use strict;
 use warnings;
-use FindBin;
 use Storable ();
 use Parrot::PMC ();
 use Parrot::Pmc2c::VTable ();
@@ -88,7 +87,7 @@
         unless ( defined $allargsref->{args} and ref( $allargsref->{args} ) eq 
q{ARRAY} );
 
     unshift @{ $allargsref->{include} },
-        ( ".", "$FindBin::Bin/../..", "$FindBin::Bin/../../src/pmc/" );
+        ( ".", "$allargsref->{bin}/../..", "$allargsref->{bin}/../../src/pmc/" 
);
 
     foreach my $opt qw(nolines) {
         if ( !defined $allargsref->{opt}{$opt} ) {
@@ -100,7 +99,7 @@
 
 =head3 C<dump_vtable()>
 
-    $self->dump_vtable("$FindBin::Bin/../../src/vtable.tbl");
+    $self->dump_vtable("$Bin/../../src/vtable.tbl");
 
 B<Purpose:>  Create a F<.dump> file for the default vtable (from which
 all PMCs inherit).
Index: t/tools/pmc2cutils/05-gen_c.t
===================================================================
--- t/tools/pmc2cutils/05-gen_c.t       (revision 26514)
+++ t/tools/pmc2cutils/05-gen_c.t       (working copy)
@@ -65,6 +65,7 @@
             include => [EMAIL PROTECTED],
             opt     => \%opt,
             args    => [EMAIL PROTECTED],
+            bin     => $Bin,
         }
     );
     isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
@@ -106,6 +107,7 @@
             include => [EMAIL PROTECTED],
             opt     => \%opt,
             args    => [EMAIL PROTECTED],
+            bin     => $Bin,
         }
     );
     isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
@@ -148,6 +150,7 @@
             include => [EMAIL PROTECTED],
             opt     => \%opt,
             args    => [EMAIL PROTECTED],
+            bin     => $Bin,
         }
     );
     isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
@@ -198,6 +201,7 @@
             include => [EMAIL PROTECTED],
             opt     => \%opt,
             args    => [EMAIL PROTECTED],
+            bin     => $Bin,
         }
     );
     isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
Index: t/tools/pmc2cutils/02-find_file.t
===================================================================
--- t/tools/pmc2cutils/02-find_file.t   (revision 26514)
+++ t/tools/pmc2cutils/02-find_file.t   (working copy)
@@ -32,6 +32,7 @@
         include => [EMAIL PROTECTED],
         opt     => \%opt,
         args    => [EMAIL PROTECTED],
+        bin     => $Bin,
     }
 );
 
Index: t/tools/pmc2cutils/06-print_tree.t
===================================================================
--- t/tools/pmc2cutils/06-print_tree.t  (revision 26514)
+++ t/tools/pmc2cutils/06-print_tree.t  (working copy)
@@ -65,6 +65,7 @@
             include => [EMAIL PROTECTED],
             opt     => \%opt,
             args    => [EMAIL PROTECTED],
+            bin     => $Bin,
         }
     );
     isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
@@ -114,6 +115,7 @@
             include => [EMAIL PROTECTED],
             opt     => \%opt,
             args    => [EMAIL PROTECTED],
+            bin     => $Bin,
         }
     );
     isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
@@ -167,6 +169,7 @@
             include => [EMAIL PROTECTED],
             opt     => \%opt,
             args    => [EMAIL PROTECTED],
+            bin     => $Bin,
         }
     );
     isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
@@ -220,6 +223,7 @@
             include => [EMAIL PROTECTED],
             opt     => \%opt,
             args    => [EMAIL PROTECTED],
+            bin     => $Bin,
         }
     );
     isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
@@ -269,6 +273,7 @@
             include => [EMAIL PROTECTED],
             opt     => \%opt,
             args    => [EMAIL PROTECTED],
+            bin     => $Bin,
         }
     );
     isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
Index: t/tools/pmc2cutils/03-dump_vtable.t
===================================================================
--- t/tools/pmc2cutils/03-dump_vtable.t (revision 26514)
+++ t/tools/pmc2cutils/03-dump_vtable.t (working copy)
@@ -41,6 +41,7 @@
             include => [EMAIL PROTECTED],
             opt     => \%opt,
             args    => [EMAIL PROTECTED],
+            bin     => $Bin,
         }
     );
     $dump_file = $self->dump_vtable("$main::topdir/src/vtable.tbl");
Index: t/tools/pmc2cutils/01-pmc2cutils.t
===================================================================
--- t/tools/pmc2cutils/01-pmc2cutils.t  (revision 26514)
+++ t/tools/pmc2cutils/01-pmc2cutils.t  (working copy)
@@ -31,6 +31,7 @@
         include => [EMAIL PROTECTED],
         opt     => \%opt,
         args    => [EMAIL PROTECTED],
+        bin     => $Bin,
     }
 );
 isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
Index: t/tools/pmc2cutils/04-dump_pmc.t
===================================================================
--- t/tools/pmc2cutils/04-dump_pmc.t    (revision 26514)
+++ t/tools/pmc2cutils/04-dump_pmc.t    (working copy)
@@ -62,6 +62,7 @@
             include => [EMAIL PROTECTED],
             opt     => \%opt,
             args    => [EMAIL PROTECTED],
+            bin     => $Bin,
         }
     );
     isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
@@ -100,6 +101,7 @@
             include => [EMAIL PROTECTED],
             opt     => \%opt,
             args    => [EMAIL PROTECTED],
+            bin     => $Bin,
         }
     );
     isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
@@ -141,6 +143,7 @@
             include => [EMAIL PROTECTED],
             opt     => \%opt,
             args    => [EMAIL PROTECTED],
+            bin     => $Bin,
         }
     );
     isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
@@ -156,6 +159,7 @@
             include => [EMAIL PROTECTED],
             opt     => \%opt,
             args    => [EMAIL PROTECTED],
+            bin     => $Bin,
         }
     );
     isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
@@ -191,6 +195,7 @@
             include => [EMAIL PROTECTED],
             opt     => \%opt,
             args    => [EMAIL PROTECTED],
+            bin     => $Bin,
         }
     );
     isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
@@ -236,6 +241,7 @@
             include => [EMAIL PROTECTED],
             opt     => \%opt,
             args    => [EMAIL PROTECTED],
+            bin     => $Bin,
         }
     );
     isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
@@ -287,6 +293,7 @@
             include => [EMAIL PROTECTED],
             opt     => \%opt,
             args    => [EMAIL PROTECTED],
+            bin     => $Bin,
         }
     );
     isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
@@ -329,6 +336,7 @@
             include => [EMAIL PROTECTED],
             opt     => \%opt,
             args    => [EMAIL PROTECTED],
+            bin     => $Bin,
         }
     );
     isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
@@ -368,6 +376,7 @@
             include => [EMAIL PROTECTED],
             opt     => \%opt,
             args    => [EMAIL PROTECTED],
+            bin     => $Bin,
         }
     );
     isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
@@ -411,6 +420,7 @@
             include => [EMAIL PROTECTED],
             opt     => \%opt,
             args    => [EMAIL PROTECTED],
+            bin     => $Bin,
         }
     );
     isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
@@ -468,6 +478,7 @@
             include => [EMAIL PROTECTED],
             opt     => \%opt,
             args    => [EMAIL PROTECTED],
+            bin     => $Bin,
         }
     );
     isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );

Reply via email to