Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Class/Factory/Util.pm |
Statements | Executed 43 statements in 550µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
7 | 1 | 1 | 56µs | 122µs | _scandir | Class::Factory::Util::
1 | 1 | 1 | 52µs | 184µs | _subclasses | Class::Factory::Util::
7 | 1 | 1 | 20µs | 20µs | CORE:ftdir (opcode) | Class::Factory::Util::
1 | 1 | 1 | 17µs | 17µs | CORE:readdir (opcode) | Class::Factory::Util::
1 | 1 | 1 | 16µs | 19µs | BEGIN@3 | Class::Factory::Util::
5 | 1 | 1 | 15µs | 15µs | CORE:ftfile (opcode) | Class::Factory::Util::
1 | 1 | 1 | 12µs | 12µs | CORE:open_dir (opcode) | Class::Factory::Util::
1 | 1 | 1 | 8µs | 8µs | import | Class::Factory::Util::
1 | 1 | 1 | 7µs | 33µs | BEGIN@6 | Class::Factory::Util::
1 | 1 | 1 | 7µs | 19µs | BEGIN@17 | Class::Factory::Util::
1 | 1 | 1 | 6µs | 31µs | BEGIN@4 | Class::Factory::Util::
1 | 1 | 1 | 6µs | 6µs | CORE:subst (opcode) | Class::Factory::Util::
1 | 1 | 1 | 4µs | 4µs | CORE:sort (opcode) | Class::Factory::Util::
1 | 1 | 1 | 2µs | 2µs | CORE:closedir (opcode) | Class::Factory::Util::
0 | 0 | 0 | 0s | 0s | subclasses | Class::Factory::Util::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Class::Factory::Util; | ||||
2 | |||||
3 | 3 | 23µs | 2 | 23µs | # spent 19µs (16+4) within Class::Factory::Util::BEGIN@3 which was called:
# once (16µs+4µs) by DateTime::Format::Builder::Parser::BEGIN@626 at line 3 # spent 19µs making 1 call to Class::Factory::Util::BEGIN@3
# spent 4µs making 1 call to strict::import |
4 | 3 | 20µs | 2 | 56µs | # spent 31µs (6+25) within Class::Factory::Util::BEGIN@4 which was called:
# once (6µs+25µs) by DateTime::Format::Builder::Parser::BEGIN@626 at line 4 # spent 31µs making 1 call to Class::Factory::Util::BEGIN@4
# spent 25µs making 1 call to vars::import |
5 | |||||
6 | 3 | 34µs | 2 | 59µs | # spent 33µs (7+26) within Class::Factory::Util::BEGIN@6 which was called:
# once (7µs+26µs) by DateTime::Format::Builder::Parser::BEGIN@626 at line 6 # spent 33µs making 1 call to Class::Factory::Util::BEGIN@6
# spent 26µs making 1 call to Exporter::import |
7 | |||||
8 | 1 | 600ns | $VERSION = '1.7'; | ||
9 | |||||
10 | 1 | 3µs | 1; | ||
11 | |||||
12 | sub import | ||||
13 | # spent 8µs within Class::Factory::Util::import which was called:
# once (8µs+0s) by DateTime::Format::Builder::Parser::BEGIN@626 at line 626 of DateTime/Format/Builder/Parser.pm | ||||
14 | 2 | 5µs | my $caller = caller(0); | ||
15 | |||||
16 | { | ||||
17 | 3 | 273µs | 2 | 31µs | # spent 19µs (7+12) within Class::Factory::Util::BEGIN@17 which was called:
# once (7µs+12µs) by DateTime::Format::Builder::Parser::BEGIN@626 at line 17 # spent 19µs making 1 call to Class::Factory::Util::BEGIN@17
# spent 12µs making 1 call to strict::unimport |
18 | 1 | 6µs | *{"${caller}::subclasses"} = \&_subclasses; | ||
19 | } | ||||
20 | } | ||||
21 | |||||
22 | # deprecated | ||||
23 | sub subclasses { _subclasses(@_) } | ||||
24 | |||||
25 | sub _subclasses | ||||
26 | # spent 184µs (52+132) within Class::Factory::Util::_subclasses which was called:
# once (52µs+132µs) by DateTime::Format::SQLite::BEGIN@16 at line 628 of DateTime/Format/Builder/Parser.pm | ||||
27 | 8 | 56µs | my $base = shift; | ||
28 | |||||
29 | 1 | 6µs | $base =~ s,::,/,g; # spent 6µs making 1 call to Class::Factory::Util::CORE:subst | ||
30 | |||||
31 | my %dirs = map { $_ => 1 } @INC; | ||||
32 | |||||
33 | my $dir = substr( $INC{"$base.pm"}, 0, (length $INC{"$base.pm"}) - 3 ); | ||||
34 | |||||
35 | $dirs{$dir} = 1; | ||||
36 | |||||
37 | 7 | 122µs | my @packages = map { _scandir( "$_/$base" ) } keys %dirs; # spent 122µs making 7 calls to Class::Factory::Util::_scandir, avg 17µs/call | ||
38 | |||||
39 | # Make list of unique elements | ||||
40 | my %packages = map { $_ => 1 } @packages; | ||||
41 | |||||
42 | 1 | 4µs | return sort keys %packages; # spent 4µs making 1 call to Class::Factory::Util::CORE:sort | ||
43 | } | ||||
44 | |||||
45 | sub _scandir | ||||
46 | # spent 122µs (56+66) within Class::Factory::Util::_scandir which was called 7 times, avg 17µs/call:
# 7 times (56µs+66µs) by Class::Factory::Util::_subclasses at line 37, avg 17µs/call | ||||
47 | 18 | 129µs | my $dir = shift; | ||
48 | |||||
49 | 7 | 20µs | return unless -d $dir; # spent 20µs making 7 calls to Class::Factory::Util::CORE:ftdir, avg 3µs/call | ||
50 | |||||
51 | 1 | 12µs | opendir DIR, $dir # spent 12µs making 1 call to Class::Factory::Util::CORE:open_dir | ||
52 | or confess ("Cannot open directory $dir: $!"); | ||||
53 | |||||
54 | my @packages = | ||||
55 | ( map { substr($_, 0, length($_) - 3) } | ||||
56 | 6 | 32µs | grep { substr($_, -3) eq '.pm' && -f "$dir/$_" } # spent 17µs making 1 call to Class::Factory::Util::CORE:readdir
# spent 15µs making 5 calls to Class::Factory::Util::CORE:ftfile, avg 3µs/call | ||
57 | readdir DIR | ||||
58 | ); | ||||
59 | |||||
60 | 1 | 2µs | closedir DIR # spent 2µs making 1 call to Class::Factory::Util::CORE:closedir | ||
61 | or confess("Cannot close directory $dir: $!" ); | ||||
62 | |||||
63 | return @packages; | ||||
64 | } | ||||
65 | |||||
66 | __END__ | ||||
# spent 2µs within Class::Factory::Util::CORE:closedir which was called:
# once (2µs+0s) by Class::Factory::Util::_scandir at line 60 | |||||
# spent 20µs within Class::Factory::Util::CORE:ftdir which was called 7 times, avg 3µs/call:
# 7 times (20µs+0s) by Class::Factory::Util::_scandir at line 49, avg 3µs/call | |||||
# spent 15µs within Class::Factory::Util::CORE:ftfile which was called 5 times, avg 3µs/call:
# 5 times (15µs+0s) by Class::Factory::Util::_scandir at line 56, avg 3µs/call | |||||
# spent 12µs within Class::Factory::Util::CORE:open_dir which was called:
# once (12µs+0s) by Class::Factory::Util::_scandir at line 51 | |||||
# spent 17µs within Class::Factory::Util::CORE:readdir which was called:
# once (17µs+0s) by Class::Factory::Util::_scandir at line 56 | |||||
# spent 4µs within Class::Factory::Util::CORE:sort which was called:
# once (4µs+0s) by Class::Factory::Util::_subclasses at line 42 | |||||
# spent 6µs within Class::Factory::Util::CORE:subst which was called:
# once (6µs+0s) by Class::Factory::Util::_subclasses at line 29 |