Filename | /usr/share/perl5/Class/Factory/Util.pm |
Statements | Executed 88 statements in 1.23ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
22 | 1 | 1 | 212µs | 453µs | _scandir | Class::Factory::Util::
2 | 2 | 2 | 187µs | 664µs | _subclasses | Class::Factory::Util::
22 | 1 | 1 | 117µs | 117µs | CORE:ftdir (opcode) | Class::Factory::Util::
2 | 1 | 1 | 45µs | 45µs | CORE:open_dir (opcode) | Class::Factory::Util::
2 | 1 | 1 | 38µs | 38µs | CORE:readdir (opcode) | Class::Factory::Util::
1 | 1 | 1 | 27µs | 32µs | BEGIN@3 | Class::Factory::Util::
8 | 1 | 1 | 26µs | 26µs | CORE:ftfile (opcode) | Class::Factory::Util::
2 | 2 | 2 | 21µs | 21µs | import | Class::Factory::Util::
1 | 1 | 1 | 19µs | 57µs | BEGIN@4 | Class::Factory::Util::
2 | 1 | 1 | 15µs | 15µs | CORE:closedir (opcode) | Class::Factory::Util::
1 | 1 | 1 | 12µs | 53µs | BEGIN@6 | Class::Factory::Util::
2 | 1 | 1 | 12µs | 12µs | CORE:sort (opcode) | Class::Factory::Util::
2 | 1 | 1 | 12µs | 12µs | CORE:subst (opcode) | Class::Factory::Util::
1 | 1 | 1 | 10µs | 24µs | BEGIN@17 | 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 | 54µs | 2 | 38µs | # spent 32µs (27+5) within Class::Factory::Util::BEGIN@3 which was called:
# once (27µs+5µs) by DateTime::Format::Builder::Parser::BEGIN@626 at line 3 # spent 32µs making 1 call to Class::Factory::Util::BEGIN@3
# spent 5µs making 1 call to strict::import |
4 | 3 | 54µs | 2 | 95µs | # spent 57µs (19+38) within Class::Factory::Util::BEGIN@4 which was called:
# once (19µs+38µs) by DateTime::Format::Builder::Parser::BEGIN@626 at line 4 # spent 57µs making 1 call to Class::Factory::Util::BEGIN@4
# spent 38µs making 1 call to vars::import |
5 | |||||
6 | 3 | 62µs | 2 | 93µs | # spent 53µs (12+40) within Class::Factory::Util::BEGIN@6 which was called:
# once (12µs+40µs) by DateTime::Format::Builder::Parser::BEGIN@626 at line 6 # spent 53µs making 1 call to Class::Factory::Util::BEGIN@6
# spent 40µs making 1 call to Exporter::import |
7 | |||||
8 | 1 | 1µs | $VERSION = '1.7'; | ||
9 | |||||
10 | 1 | 3µs | 1; | ||
11 | |||||
12 | sub import | ||||
13 | # spent 21µs within Class::Factory::Util::import which was called 2 times, avg 10µs/call:
# once (11µs+0s) by DateTime::Format::Builder::Parser::BEGIN@626 at line 626 of DateTime/Format/Builder/Parser.pm
# once (10µs+0s) by C4::ClassSortRoutine::BEGIN@24 at line 24 of /usr/share/koha/lib/C4/ClassSortRoutine.pm | ||||
14 | 2 | 3µs | my $caller = caller(0); | ||
15 | |||||
16 | { | ||||
17 | 5 | 374µs | 2 | 39µs | # spent 24µs (10+15) within Class::Factory::Util::BEGIN@17 which was called:
# once (10µs+15µs) by DateTime::Format::Builder::Parser::BEGIN@626 at line 17 # spent 24µs making 1 call to Class::Factory::Util::BEGIN@17
# spent 15µs making 1 call to strict::unimport |
18 | 2 | 13µs | *{"${caller}::subclasses"} = \&_subclasses; | ||
19 | } | ||||
20 | } | ||||
21 | |||||
22 | # deprecated | ||||
23 | sub subclasses { _subclasses(@_) } | ||||
24 | |||||
25 | sub _subclasses | ||||
26 | # spent 664µs (187+477) within Class::Factory::Util::_subclasses which was called 2 times, avg 332µs/call:
# once (121µs+318µs) by DateTime::Format::MySQL::BEGIN@11 at line 628 of DateTime/Format/Builder/Parser.pm
# once (66µs+159µs) by C4::ClassSortRoutine::GetSortRoutineNames at line 80 of /usr/share/koha/lib/C4/ClassSortRoutine.pm | ||||
27 | 2 | 2µs | my $base = shift; | ||
28 | |||||
29 | 2 | 36µs | 2 | 12µs | $base =~ s,::,/,g; # spent 12µs making 2 calls to Class::Factory::Util::CORE:subst, avg 6µs/call |
30 | |||||
31 | 2 | 30µs | my %dirs = map { $_ => 1 } @INC; | ||
32 | |||||
33 | 2 | 11µs | my $dir = substr( $INC{"$base.pm"}, 0, (length $INC{"$base.pm"}) - 3 ); | ||
34 | |||||
35 | 2 | 3µs | $dirs{$dir} = 1; | ||
36 | |||||
37 | 2 | 71µs | 22 | 453µs | my @packages = map { _scandir( "$_/$base" ) } keys %dirs; # spent 453µs making 22 calls to Class::Factory::Util::_scandir, avg 21µs/call |
38 | |||||
39 | # Make list of unique elements | ||||
40 | 2 | 11µs | my %packages = map { $_ => 1 } @packages; | ||
41 | |||||
42 | 2 | 36µs | 2 | 12µs | return sort keys %packages; # spent 12µs making 2 calls to Class::Factory::Util::CORE:sort, avg 6µs/call |
43 | } | ||||
44 | |||||
45 | sub _scandir | ||||
46 | # spent 453µs (212+241) within Class::Factory::Util::_scandir which was called 22 times, avg 21µs/call:
# 22 times (212µs+241µs) by Class::Factory::Util::_subclasses at line 37, avg 21µs/call | ||||
47 | 22 | 20µs | my $dir = shift; | ||
48 | |||||
49 | 22 | 237µs | 22 | 117µs | return unless -d $dir; # spent 117µs making 22 calls to Class::Factory::Util::CORE:ftdir, avg 5µs/call |
50 | |||||
51 | 2 | 64µs | 2 | 45µs | opendir DIR, $dir # spent 45µs making 2 calls to Class::Factory::Util::CORE:open_dir, avg 23µs/call |
52 | or confess ("Cannot open directory $dir: $!"); | ||||
53 | |||||
54 | my @packages = | ||||
55 | ( map { substr($_, 0, length($_) - 3) } | ||||
56 | 2 | 113µs | 10 | 64µs | grep { substr($_, -3) eq '.pm' && -f "$dir/$_" } # spent 38µs making 2 calls to Class::Factory::Util::CORE:readdir, avg 19µs/call
# spent 26µs making 8 calls to Class::Factory::Util::CORE:ftfile, avg 3µs/call |
57 | readdir DIR | ||||
58 | ); | ||||
59 | |||||
60 | 2 | 25µs | 2 | 15µs | closedir DIR # spent 15µs making 2 calls to Class::Factory::Util::CORE:closedir, avg 7µs/call |
61 | or confess("Cannot close directory $dir: $!" ); | ||||
62 | |||||
63 | 2 | 8µs | return @packages; | ||
64 | } | ||||
65 | |||||
66 | __END__ | ||||
# spent 15µs within Class::Factory::Util::CORE:closedir which was called 2 times, avg 7µs/call:
# 2 times (15µs+0s) by Class::Factory::Util::_scandir at line 60, avg 7µs/call | |||||
# spent 117µs within Class::Factory::Util::CORE:ftdir which was called 22 times, avg 5µs/call:
# 22 times (117µs+0s) by Class::Factory::Util::_scandir at line 49, avg 5µs/call | |||||
# spent 26µs within Class::Factory::Util::CORE:ftfile which was called 8 times, avg 3µs/call:
# 8 times (26µs+0s) by Class::Factory::Util::_scandir at line 56, avg 3µs/call | |||||
# spent 45µs within Class::Factory::Util::CORE:open_dir which was called 2 times, avg 23µs/call:
# 2 times (45µs+0s) by Class::Factory::Util::_scandir at line 51, avg 23µs/call | |||||
# spent 38µs within Class::Factory::Util::CORE:readdir which was called 2 times, avg 19µs/call:
# 2 times (38µs+0s) by Class::Factory::Util::_scandir at line 56, avg 19µs/call | |||||
# spent 12µs within Class::Factory::Util::CORE:sort which was called 2 times, avg 6µs/call:
# 2 times (12µs+0s) by Class::Factory::Util::_subclasses at line 42, avg 6µs/call | |||||
# spent 12µs within Class::Factory::Util::CORE:subst which was called 2 times, avg 6µs/call:
# 2 times (12µs+0s) by Class::Factory::Util::_subclasses at line 29, avg 6µs/call |