Filename | /usr/share/perl5/Class/Factory/Util.pm |
Statements | Executed 88 statements in 1.24ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
22 | 1 | 1 | 189µs | 411µs | _scandir | Class::Factory::Util::
2 | 2 | 2 | 188µs | 626µs | _subclasses | Class::Factory::Util::
22 | 1 | 1 | 94µs | 94µs | CORE:ftdir (opcode) | Class::Factory::Util::
2 | 1 | 1 | 46µs | 46µs | CORE:open_dir (opcode) | Class::Factory::Util::
2 | 1 | 1 | 42µs | 42µs | CORE:readdir (opcode) | Class::Factory::Util::
1 | 1 | 1 | 30µs | 40µs | BEGIN@3 | Class::Factory::Util::
8 | 1 | 1 | 24µs | 24µs | CORE:ftfile (opcode) | Class::Factory::Util::
2 | 2 | 2 | 23µs | 23µs | import | Class::Factory::Util::
2 | 1 | 1 | 16µs | 16µs | CORE:closedir (opcode) | Class::Factory::Util::
1 | 1 | 1 | 15µs | 74µs | BEGIN@6 | Class::Factory::Util::
2 | 1 | 1 | 14µs | 14µs | CORE:subst (opcode) | Class::Factory::Util::
2 | 1 | 1 | 13µs | 13µs | CORE:sort (opcode) | Class::Factory::Util::
1 | 1 | 1 | 13µs | 33µs | BEGIN@17 | Class::Factory::Util::
1 | 1 | 1 | 11µs | 51µs | BEGIN@4 | 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 | 120µs | 2 | 50µs | # spent 40µs (30+10) within Class::Factory::Util::BEGIN@3 which was called:
# once (30µs+10µs) by DateTime::Format::Builder::Parser::BEGIN@626 at line 3 # spent 40µs making 1 call to Class::Factory::Util::BEGIN@3
# spent 10µs making 1 call to strict::import |
4 | 3 | 33µs | 2 | 90µs | # spent 51µs (11+39) within Class::Factory::Util::BEGIN@4 which was called:
# once (11µs+39µs) by DateTime::Format::Builder::Parser::BEGIN@626 at line 4 # spent 51µs making 1 call to Class::Factory::Util::BEGIN@4
# spent 39µs making 1 call to vars::import |
5 | |||||
6 | 3 | 72µs | 2 | 132µs | # spent 74µs (15+58) within Class::Factory::Util::BEGIN@6 which was called:
# once (15µs+58µs) by DateTime::Format::Builder::Parser::BEGIN@626 at line 6 # spent 74µs making 1 call to Class::Factory::Util::BEGIN@6
# spent 58µs making 1 call to Exporter::import |
7 | |||||
8 | 1 | 800ns | $VERSION = '1.7'; | ||
9 | |||||
10 | 1 | 4µs | 1; | ||
11 | |||||
12 | sub import | ||||
13 | # spent 23µs within Class::Factory::Util::import which was called 2 times, avg 12µs/call:
# once (12µs+0s) by DateTime::Format::Builder::Parser::BEGIN@626 at line 626 of DateTime/Format/Builder/Parser.pm
# once (11µs+0s) by C4::ClassSortRoutine::BEGIN@24 at line 24 of /usr/share/koha/lib/C4/ClassSortRoutine.pm | ||||
14 | 4 | 16µs | my $caller = caller(0); | ||
15 | |||||
16 | { | ||||
17 | 3 | 349µs | 2 | 53µs | # spent 33µs (13+20) within Class::Factory::Util::BEGIN@17 which was called:
# once (13µs+20µs) by DateTime::Format::Builder::Parser::BEGIN@626 at line 17 # spent 33µs making 1 call to Class::Factory::Util::BEGIN@17
# spent 20µs making 1 call to strict::unimport |
18 | 2 | 15µs | *{"${caller}::subclasses"} = \&_subclasses; | ||
19 | } | ||||
20 | } | ||||
21 | |||||
22 | # deprecated | ||||
23 | sub subclasses { _subclasses(@_) } | ||||
24 | |||||
25 | sub _subclasses | ||||
26 | # spent 626µs (188+438) within Class::Factory::Util::_subclasses which was called 2 times, avg 313µs/call:
# once (107µs+252µs) by DateTime::Format::MySQL::BEGIN@11 at line 628 of DateTime/Format/Builder/Parser.pm
# once (81µs+186µs) by C4::ClassSortRoutine::GetSortRoutineNames at line 80 of /usr/share/koha/lib/C4/ClassSortRoutine.pm | ||||
27 | 16 | 207µs | my $base = shift; | ||
28 | |||||
29 | 2 | 14µs | $base =~ s,::,/,g; # spent 14µs making 2 calls to Class::Factory::Util::CORE:subst, avg 7µs/call | ||
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 | 22 | 411µs | my @packages = map { _scandir( "$_/$base" ) } keys %dirs; # spent 411µs making 22 calls to Class::Factory::Util::_scandir, avg 19µs/call | ||
38 | |||||
39 | # Make list of unique elements | ||||
40 | my %packages = map { $_ => 1 } @packages; | ||||
41 | |||||
42 | 2 | 13µs | return sort keys %packages; # spent 13µs making 2 calls to Class::Factory::Util::CORE:sort, avg 6µs/call | ||
43 | } | ||||
44 | |||||
45 | sub _scandir | ||||
46 | # spent 411µs (189+222) within Class::Factory::Util::_scandir which was called 22 times, avg 19µs/call:
# 22 times (189µs+222µs) by Class::Factory::Util::_subclasses at line 37, avg 19µs/call | ||||
47 | 52 | 422µs | my $dir = shift; | ||
48 | |||||
49 | 22 | 94µs | return unless -d $dir; # spent 94µs making 22 calls to Class::Factory::Util::CORE:ftdir, avg 4µs/call | ||
50 | |||||
51 | 2 | 46µs | opendir DIR, $dir # spent 46µ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 | 10 | 66µs | grep { substr($_, -3) eq '.pm' && -f "$dir/$_" } # spent 42µs making 2 calls to Class::Factory::Util::CORE:readdir, avg 21µs/call
# spent 24µs making 8 calls to Class::Factory::Util::CORE:ftfile, avg 3µs/call | ||
57 | readdir DIR | ||||
58 | ); | ||||
59 | |||||
60 | 2 | 16µs | closedir DIR # spent 16µs making 2 calls to Class::Factory::Util::CORE:closedir, avg 8µs/call | ||
61 | or confess("Cannot close directory $dir: $!" ); | ||||
62 | |||||
63 | return @packages; | ||||
64 | } | ||||
65 | |||||
66 | __END__ | ||||
# spent 16µs within Class::Factory::Util::CORE:closedir which was called 2 times, avg 8µs/call:
# 2 times (16µs+0s) by Class::Factory::Util::_scandir at line 60, avg 8µs/call | |||||
# spent 94µs within Class::Factory::Util::CORE:ftdir which was called 22 times, avg 4µs/call:
# 22 times (94µs+0s) by Class::Factory::Util::_scandir at line 49, avg 4µs/call | |||||
# spent 24µs within Class::Factory::Util::CORE:ftfile which was called 8 times, avg 3µs/call:
# 8 times (24µs+0s) by Class::Factory::Util::_scandir at line 56, avg 3µs/call | |||||
# spent 46µs within Class::Factory::Util::CORE:open_dir which was called 2 times, avg 23µs/call:
# 2 times (46µs+0s) by Class::Factory::Util::_scandir at line 51, avg 23µs/call | |||||
# spent 42µs within Class::Factory::Util::CORE:readdir which was called 2 times, avg 21µs/call:
# 2 times (42µs+0s) by Class::Factory::Util::_scandir at line 56, avg 21µs/call | |||||
# spent 13µs within Class::Factory::Util::CORE:sort which was called 2 times, avg 6µs/call:
# 2 times (13µs+0s) by Class::Factory::Util::_subclasses at line 42, avg 6µs/call | |||||
# spent 14µs within Class::Factory::Util::CORE:subst which was called 2 times, avg 7µs/call:
# 2 times (14µs+0s) by Class::Factory::Util::_subclasses at line 29, avg 7µs/call |