← Index
NYTProf Performance Profile   « line view »
For script/ponapi
  Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:09 2016

Filename/usr/share/perl5/Devel/InnerPackage.pm
StatementsExecuted 39 statements in 736µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111743µs838µsDevel::InnerPackage::::BEGIN@4Devel::InnerPackage::BEGIN@4
111172µs1.23msDevel::InnerPackage::::BEGIN@7Devel::InnerPackage::BEGIN@7
41131µs32µsDevel::InnerPackage::::list_packagesDevel::InnerPackage::list_packages
11117µs32µsDevel::InnerPackage::::BEGIN@3Devel::InnerPackage::BEGIN@3
1117µs15µsDevel::InnerPackage::::BEGIN@87Devel::InnerPackage::BEGIN@87
1116µs30µsDevel::InnerPackage::::BEGIN@5Devel::InnerPackage::BEGIN@5
1116µs15µsDevel::InnerPackage::::BEGIN@67Devel::InnerPackage::BEGIN@67
4112µs2µsDevel::InnerPackage::::CORE:matchDevel::InnerPackage::CORE:match (opcode)
0000s0sDevel::InnerPackage::::_loadedDevel::InnerPackage::_loaded
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Devel::InnerPackage;
2
3239µs246µs
# spent 32µs (17+15) within Devel::InnerPackage::BEGIN@3 which was called: # once (17µs+15µs) by Module::Pluggable::Object::BEGIN@8 at line 3
use strict;
# spent 32µs making 1 call to Devel::InnerPackage::BEGIN@3 # spent 15µs making 1 call to strict::import
42115µs2894µs
# spent 838µs (743+96) within Devel::InnerPackage::BEGIN@4 which was called: # once (743µs+96µs) by Module::Pluggable::Object::BEGIN@8 at line 4
use base qw(Exporter);
# spent 838µs making 1 call to Devel::InnerPackage::BEGIN@4 # spent 55µs making 1 call to base::import
5224µs254µs
# spent 30µs (6+24) within Devel::InnerPackage::BEGIN@5 which was called: # once (6µs+24µs) by Module::Pluggable::Object::BEGIN@8 at line 5
use vars qw($VERSION @EXPORT_OK);
# spent 30µs making 1 call to Devel::InnerPackage::BEGIN@5 # spent 24µs making 1 call to vars::import
6
72238µs21.23ms
# spent 1.23ms (172µs+1.05) within Devel::InnerPackage::BEGIN@7 which was called: # once (172µs+1.05ms) by Module::Pluggable::Object::BEGIN@8 at line 7
use if $] > 5.017, 'deprecate';
# spent 1.23ms making 1 call to Devel::InnerPackage::BEGIN@7 # spent 4µs making 1 call to if::import
8
91400ns$VERSION = '0.4';
101700ns@EXPORT_OK = qw(list_packages);
11
12=pod
13
14=head1 NAME
15
16Devel::InnerPackage - find all the inner packages of a package
17
18=head1 SYNOPSIS
19
20 use Foo::Bar;
21 use Devel::InnerPackage qw(list_packages);
22
23 my @inner_packages = list_packages('Foo::Bar');
24
25
26=head1 DESCRIPTION
27
28
29Given a file like this
30
31
32 package Foo::Bar;
33
34 sub foo {}
35
36
37 package Foo::Bar::Quux;
38
39 sub quux {}
40
41 package Foo::Bar::Quirka;
42
43 sub quirka {}
44
45 1;
46
47then
48
49 list_packages('Foo::Bar');
50
51will return
52
53 Foo::Bar::Quux
54 Foo::Bar::Quirka
55
56=head1 METHODS
57
58=head2 list_packages <package name>
59
60Return a list of all inner packages of that package.
61
62=cut
63
64
# spent 32µs (31+2) within Devel::InnerPackage::list_packages which was called 4 times, avg 8µs/call: # 4 times (31µs+2µs) by Module::Pluggable::Object::handle_innerpackages at line 351 of Module/Pluggable/Object.pm, avg 8µs/call
sub list_packages {
65813µs42µs my $pack = shift; $pack .= "::" unless $pack =~ m!::$!;
# spent 2µs making 4 calls to Devel::InnerPackage::CORE:match, avg 450ns/call
66
672158µs225µs
# spent 15µs (6+9) within Devel::InnerPackage::BEGIN@67 which was called: # once (6µs+9µs) by Module::Pluggable::Object::BEGIN@8 at line 67
no strict 'refs';
# spent 15µs making 1 call to Devel::InnerPackage::BEGIN@67 # spent 9µs making 1 call to strict::unimport
684500ns my @packs;
6948µs my @stuff = grep !/^(main|)::$/, keys %{$pack};
7045µs for my $cand (grep /::$/, @stuff)
71 {
72 $cand =~ s!::$!!;
73 my @children = list_packages($pack.$cand);
74
75 push @packs, "$pack$cand" unless $cand =~ /^::/ ||
76 !__PACKAGE__->_loaded($pack.$cand); # or @children;
77 push @packs, @children;
78 }
79410µs return grep {$_ !~ /::(::ISA::CACHE|SUPER)/} @packs;
80}
81
82### XXX this is an inlining of the Class-Inspector->loaded()
83### method, but inlined to remove the dependency.
84sub _loaded {
85 my ($class, $name) = @_;
86
872123µs224µs
# spent 15µs (7+8) within Devel::InnerPackage::BEGIN@87 which was called: # once (7µs+8µs) by Module::Pluggable::Object::BEGIN@8 at line 87
no strict 'refs';
# spent 15µs making 1 call to Devel::InnerPackage::BEGIN@87 # spent 8µs making 1 call to strict::unimport
88
89 # Handle by far the two most common cases
90 # This is very fast and handles 99% of cases.
91 return 1 if defined ${"${name}::VERSION"};
92 return 1 if @{"${name}::ISA"};
93
94 # Are there any symbol table entries other than other namespaces
95 foreach ( keys %{"${name}::"} ) {
96 next if substr($_, -2, 2) eq '::';
97 return 1 if defined &{"${name}::$_"};
98 }
99
100 # No functions, and it doesn't have a version, and isn't anything.
101 # As an absolute last resort, check for an entry in %INC
102 my $filename = join( '/', split /(?:'|::)/, $name ) . '.pm';
103 return 1 if defined $INC{$filename};
104
105 '';
106}
107
108
109=head1 AUTHOR
110
111Simon Wistow <simon@thegestalt.org>
112
113=head1 COPYING
114
115Copyright, 2005 Simon Wistow
116
117Distributed under the same terms as Perl itself.
118
119=head1 BUGS
120
121None known.
122
123=cut
124
- -
12912µs1;
 
# spent 2µs within Devel::InnerPackage::CORE:match which was called 4 times, avg 450ns/call: # 4 times (2µs+0s) by Devel::InnerPackage::list_packages at line 65, avg 450ns/call
sub Devel::InnerPackage::CORE:match; # opcode