Filename | /usr/share/perl5/Class/Factory/Util.pm |
Statements | Executed 88 statements in 7.77ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
11 | 1 | 1 | 3.38ms | 3.38ms | CORE:ftfile (opcode) | Class::Factory::Util::
22 | 1 | 1 | 2.02ms | 2.02ms | CORE:ftdir (opcode) | Class::Factory::Util::
3 | 1 | 1 | 1.02ms | 1.02ms | CORE:open_dir (opcode) | Class::Factory::Util::
3 | 1 | 1 | 611µs | 611µs | CORE:readdir (opcode) | Class::Factory::Util::
22 | 1 | 1 | 186µs | 7.25ms | _scandir | Class::Factory::Util::
2 | 2 | 2 | 109µs | 7.37ms | _subclasses | Class::Factory::Util::
3 | 1 | 1 | 24µs | 24µs | CORE:closedir (opcode) | Class::Factory::Util::
1 | 1 | 1 | 16µs | 23µs | BEGIN@17 | Class::Factory::Util::
1 | 1 | 1 | 11µs | 22µs | BEGIN@3 | Class::Factory::Util::
2 | 2 | 2 | 11µs | 11µs | import | Class::Factory::Util::
1 | 1 | 1 | 10µs | 31µs | BEGIN@6 | Class::Factory::Util::
1 | 1 | 1 | 6µs | 24µs | BEGIN@4 | Class::Factory::Util::
2 | 1 | 1 | 5µs | 5µs | CORE:subst (opcode) | Class::Factory::Util::
2 | 1 | 1 | 5µs | 5µs | CORE:sort (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 | 2 | 30µs | 2 | 34µs | # spent 22µs (11+11) within Class::Factory::Util::BEGIN@3 which was called:
# once (11µs+11µs) by DateTime::Format::Builder::Parser::BEGIN@375 at line 3 # spent 22µs making 1 call to Class::Factory::Util::BEGIN@3
# spent 11µs making 1 call to strict::import |
4 | 2 | 23µs | 2 | 42µs | # spent 24µs (6+18) within Class::Factory::Util::BEGIN@4 which was called:
# once (6µs+18µs) by DateTime::Format::Builder::Parser::BEGIN@375 at line 4 # spent 24µs making 1 call to Class::Factory::Util::BEGIN@4
# spent 18µs making 1 call to vars::import |
5 | |||||
6 | 2 | 46µs | 2 | 52µs | # spent 31µs (10+21) within Class::Factory::Util::BEGIN@6 which was called:
# once (10µs+21µs) by DateTime::Format::Builder::Parser::BEGIN@375 at line 6 # spent 31µs making 1 call to Class::Factory::Util::BEGIN@6
# spent 21µs making 1 call to Exporter::import |
7 | |||||
8 | 1 | 400ns | $VERSION = '1.7'; | ||
9 | |||||
10 | 1 | 2µs | 1; | ||
11 | |||||
12 | sub import | ||||
13 | # spent 11µs within Class::Factory::Util::import which was called 2 times, avg 5µs/call:
# once (6µs+0s) by C4::ClassSortRoutine::BEGIN@24 at line 24 of C4/ClassSortRoutine.pm
# once (5µs+0s) by DateTime::Format::Builder::Parser::BEGIN@375 at line 375 of DateTime/Format/Builder/Parser.pm | ||||
14 | 2 | 2µs | my $caller = caller(0); | ||
15 | |||||
16 | { | ||||
17 | 4 | 292µs | 2 | 31µs | # spent 23µs (16+8) within Class::Factory::Util::BEGIN@17 which was called:
# once (16µs+8µs) by DateTime::Format::Builder::Parser::BEGIN@375 at line 17 # spent 23µs making 1 call to Class::Factory::Util::BEGIN@17
# spent 8µs making 1 call to strict::unimport |
18 | 2 | 7µs | *{"${caller}::subclasses"} = \&_subclasses; | ||
19 | } | ||||
20 | } | ||||
21 | |||||
22 | # deprecated | ||||
23 | sub subclasses { _subclasses(@_) } | ||||
24 | |||||
25 | sub _subclasses | ||||
26 | # spent 7.37ms (109µs+7.26) within Class::Factory::Util::_subclasses which was called 2 times, avg 3.68ms/call:
# once (54µs+6.60ms) by C4::ClassSortRoutine::GetSortRoutineNames at line 80 of C4/ClassSortRoutine.pm
# once (54µs+659µs) by DateTime::Format::MySQL::BEGIN@11 at line 377 of DateTime/Format/Builder/Parser.pm | ||||
27 | 2 | 900ns | my $base = shift; | ||
28 | |||||
29 | 2 | 14µs | 2 | 5µs | $base =~ s,::,/,g; # spent 5µs making 2 calls to Class::Factory::Util::CORE:subst, avg 3µs/call |
30 | |||||
31 | 2 | 16µs | my %dirs = map { $_ => 1 } @INC; | ||
32 | |||||
33 | 2 | 6µs | my $dir = substr( $INC{"$base.pm"}, 0, (length $INC{"$base.pm"}) - 3 ); | ||
34 | |||||
35 | 2 | 2µs | $dirs{$dir} = 1; | ||
36 | |||||
37 | 2 | 40µs | 22 | 7.25ms | my @packages = map { _scandir( "$_/$base" ) } keys %dirs; # spent 7.25ms making 22 calls to Class::Factory::Util::_scandir, avg 329µs/call |
38 | |||||
39 | # Make list of unique elements | ||||
40 | 2 | 9µs | my %packages = map { $_ => 1 } @packages; | ||
41 | |||||
42 | 2 | 25µs | 2 | 5µs | return sort keys %packages; # spent 5µs making 2 calls to Class::Factory::Util::CORE:sort, avg 2µs/call |
43 | } | ||||
44 | |||||
45 | sub _scandir | ||||
46 | # spent 7.25ms (186µs+7.06) within Class::Factory::Util::_scandir which was called 22 times, avg 329µs/call:
# 22 times (186µs+7.06ms) by Class::Factory::Util::_subclasses at line 37, avg 329µs/call | ||||
47 | 22 | 4µs | my $dir = shift; | ||
48 | |||||
49 | 22 | 2.10ms | 22 | 2.02ms | return unless -d $dir; # spent 2.02ms making 22 calls to Class::Factory::Util::CORE:ftdir, avg 92µs/call |
50 | |||||
51 | 3 | 1.04ms | 3 | 1.02ms | opendir DIR, $dir # spent 1.02ms making 3 calls to Class::Factory::Util::CORE:open_dir, avg 340µs/call |
52 | or confess ("Cannot open directory $dir: $!"); | ||||
53 | |||||
54 | my @packages = | ||||
55 | ( map { substr($_, 0, length($_) - 3) } | ||||
56 | 3 | 4.08ms | 14 | 4.00ms | grep { substr($_, -3) eq '.pm' && -f "$dir/$_" } # spent 3.38ms making 11 calls to Class::Factory::Util::CORE:ftfile, avg 308µs/call
# spent 611µs making 3 calls to Class::Factory::Util::CORE:readdir, avg 204µs/call |
57 | readdir DIR | ||||
58 | ); | ||||
59 | |||||
60 | 3 | 33µs | 3 | 24µs | closedir DIR # spent 24µs making 3 calls to Class::Factory::Util::CORE:closedir, avg 8µs/call |
61 | or confess("Cannot close directory $dir: $!" ); | ||||
62 | |||||
63 | 3 | 8µs | return @packages; | ||
64 | } | ||||
65 | |||||
66 | __END__ | ||||
# spent 24µs within Class::Factory::Util::CORE:closedir which was called 3 times, avg 8µs/call:
# 3 times (24µs+0s) by Class::Factory::Util::_scandir at line 60, avg 8µs/call | |||||
# spent 2.02ms within Class::Factory::Util::CORE:ftdir which was called 22 times, avg 92µs/call:
# 22 times (2.02ms+0s) by Class::Factory::Util::_scandir at line 49, avg 92µs/call | |||||
# spent 3.38ms within Class::Factory::Util::CORE:ftfile which was called 11 times, avg 308µs/call:
# 11 times (3.38ms+0s) by Class::Factory::Util::_scandir at line 56, avg 308µs/call | |||||
# spent 1.02ms within Class::Factory::Util::CORE:open_dir which was called 3 times, avg 340µs/call:
# 3 times (1.02ms+0s) by Class::Factory::Util::_scandir at line 51, avg 340µs/call | |||||
# spent 611µs within Class::Factory::Util::CORE:readdir which was called 3 times, avg 204µs/call:
# 3 times (611µs+0s) by Class::Factory::Util::_scandir at line 56, avg 204µs/call | |||||
# spent 5µs within Class::Factory::Util::CORE:sort which was called 2 times, avg 2µs/call:
# 2 times (5µs+0s) by Class::Factory::Util::_subclasses at line 42, avg 2µs/call | |||||
# spent 5µs within Class::Factory::Util::CORE:subst which was called 2 times, avg 3µs/call:
# 2 times (5µs+0s) by Class::Factory::Util::_subclasses at line 29, avg 3µs/call |