Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Profiling submodule dependencies within a Perl module

Tags:

profiling

perl

I've got a big collection of utility subroutines stuck in a single giant myUtil.pm Perl module. I'm trying to get a profile of how the pile of subroutines depend on each other.

I found Module::ScanDeps, which looks for dependencies across modules. Is there a similar tool which looks at dependencies within a module?

I'd prefer to have a static analysis, as I'm not very confident that I've got enough test cases to cover all of the code paths.

like image 753
ajwood Avatar asked Dec 17 '25 05:12

ajwood


1 Answers

There's probably something newer (and PPI-based), but the older B::Xref does this.

Foo.pm:

package Foo;
use 5.014;
use warnings;
sub foo { bar() }
sub bar { $_[0]-- and bar() }
sub baz { foo(); bar () }
1;

perl -MO=Xref -e'use Foo':

...
File Foo.pm
  Subroutine (definitions)
    Package Foo
      &bar              s4
      &baz              s6
      &foo              s4
  Subroutine Foo::bar
    Package Foo
      &bar              &5
  Subroutine Foo::baz
    Package Foo
      &bar              &6
      &foo              &6
  Subroutine Foo::foo
    Package Foo
      &bar              &4
like image 150
ysth Avatar answered Dec 19 '25 23:12

ysth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!