Filename | /Users/edenc/perl5/lib/perl5/KiokuDB/TypeMap.pm |
Statements | Executed 503 statements in 4.16ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
23 | 1 | 1 | 826µs | 2.64ms | resolve | KiokuDB::TypeMap::
1 | 1 | 1 | 523µs | 8.80ms | BEGIN@9 | KiokuDB::TypeMap::
1 | 1 | 1 | 476µs | 20.0ms | BEGIN@10 | KiokuDB::TypeMap::
9 | 1 | 1 | 310µs | 310µs | __ANON__[:56] | KiokuDB::TypeMap::
10 | 2 | 1 | 234µs | 207ms | BUILD (recurses: max depth 1, inclusive time 339µs) | KiokuDB::TypeMap::
3 | 1 | 1 | 122µs | 162µs | CORE:sort (opcode) | KiokuDB::TypeMap::
10 | 1 | 1 | 96µs | 143µs | _build_all_entries | KiokuDB::TypeMap::
10 | 1 | 1 | 94µs | 137µs | _build_all_isa_entries | KiokuDB::TypeMap::
9 | 1 | 1 | 48µs | 48µs | CORE:subst (opcode) | KiokuDB::TypeMap::
2 | 1 | 1 | 33µs | 33µs | CORE:regcomp (opcode) | KiokuDB::TypeMap::
4 | 1 | 1 | 28µs | 43µs | resolve_entry | KiokuDB::TypeMap::
2 | 1 | 1 | 26µs | 62µs | __ANON__[:58] | KiokuDB::TypeMap::
3 | 1 | 1 | 25µs | 192µs | _build_all_isa_entry_classes | KiokuDB::TypeMap::
1 | 1 | 1 | 21µs | 6.38ms | BEGIN@4 | KiokuDB::TypeMap::
1 | 1 | 1 | 20µs | 73µs | BEGIN@7 | KiokuDB::TypeMap::
1 | 1 | 1 | 18µs | 79µs | BEGIN@6 | KiokuDB::TypeMap::
1 | 1 | 1 | 16µs | 622µs | BEGIN@12 | KiokuDB::TypeMap::
9 | 1 | 1 | 12µs | 12µs | _build_includes | KiokuDB::TypeMap::
7 | 1 | 1 | 11µs | 11µs | _build_entries | KiokuDB::TypeMap::
2 | 1 | 1 | 3µs | 3µs | CORE:match (opcode) | KiokuDB::TypeMap::
1 | 1 | 1 | 2µs | 2µs | _build_isa_entries | KiokuDB::TypeMap::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | #!/usr/bin/perl | ||||
2 | |||||
3 | package KiokuDB::TypeMap; | ||||
4 | 2 | 84µs | 2 | 12.7ms | # spent 6.38ms (21µs+6.36) within KiokuDB::TypeMap::BEGIN@4 which was called:
# once (21µs+6.36ms) by Text::Tradition::Directory::BEGIN@9 at line 4 # spent 6.38ms making 1 call to KiokuDB::TypeMap::BEGIN@4
# spent 6.36ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:492] |
5 | |||||
6 | 2 | 48µs | 2 | 140µs | # spent 79µs (18+61) within KiokuDB::TypeMap::BEGIN@6 which was called:
# once (18µs+61µs) by Text::Tradition::Directory::BEGIN@9 at line 6 # spent 79µs making 1 call to KiokuDB::TypeMap::BEGIN@6
# spent 61µs making 1 call to Exporter::import |
7 | 2 | 48µs | 2 | 126µs | # spent 73µs (20+53) within KiokuDB::TypeMap::BEGIN@7 which was called:
# once (20µs+53µs) by Text::Tradition::Directory::BEGIN@9 at line 7 # spent 73µs making 1 call to KiokuDB::TypeMap::BEGIN@7
# spent 53µs making 1 call to Exporter::import |
8 | |||||
9 | 2 | 314µs | 2 | 8.80ms | # spent 8.80ms (523µs+8.27) within KiokuDB::TypeMap::BEGIN@9 which was called:
# once (523µs+8.27ms) by Text::Tradition::Directory::BEGIN@9 at line 9 # spent 8.80ms making 1 call to KiokuDB::TypeMap::BEGIN@9
# spent 7µs making 1 call to UNIVERSAL::import |
10 | 2 | 251µs | 2 | 20.0ms | # spent 20.0ms (476µs+19.5) within KiokuDB::TypeMap::BEGIN@10 which was called:
# once (476µs+19.5ms) by Text::Tradition::Directory::BEGIN@9 at line 10 # spent 20.0ms making 1 call to KiokuDB::TypeMap::BEGIN@10
# spent 3µs making 1 call to UNIVERSAL::import |
11 | |||||
12 | 2 | 1.38ms | 2 | 1.23ms | # spent 622µs (16+606) within KiokuDB::TypeMap::BEGIN@12 which was called:
# once (16µs+606µs) by Text::Tradition::Directory::BEGIN@9 at line 12 # spent 622µs making 1 call to KiokuDB::TypeMap::BEGIN@12
# spent 606µs making 1 call to namespace::clean::import |
13 | |||||
14 | 1 | 5µs | 1 | 8.92ms | with qw(KiokuDB::Role::TypeMap); # spent 8.92ms making 1 call to Moose::with |
15 | |||||
16 | 1 | 8µs | 1 | 14.0ms | has [qw(entries isa_entries)] => ( # spent 14.0ms making 1 call to Moose::has |
17 | #isa => "HashRef[KiokuDB::TypeMap::Entry|KiokuDB::TypeMap::Entry::Alias]", # dog slow regex | ||||
18 | is => "ro", | ||||
19 | lazy_build => 1, | ||||
20 | ); | ||||
21 | |||||
22 | 7 | 17µs | # spent 11µs within KiokuDB::TypeMap::_build_entries which was called 7 times, avg 2µs/call:
# 7 times (11µs+0s) by KiokuDB::TypeMap::entries at line 10 of (eval 83)[Eval/Closure.pm:125], avg 2µs/call | ||
23 | 1 | 3µs | # spent 2µs within KiokuDB::TypeMap::_build_isa_entries which was called:
# once (2µs+0s) by KiokuDB::TypeMap::isa_entries at line 10 of (eval 83)[Eval/Closure.pm:125] | ||
24 | |||||
25 | 1 | 7µs | 1 | 13.5ms | has [qw(all_entries all_isa_entries)] => ( # spent 13.5ms making 1 call to Moose::has |
26 | #isa => "HashRef[KiokuDB::TypeMap::Entry|KiokuDB::TypeMap::Entry::Alias]", # dog slow regex | ||||
27 | is => "ro", | ||||
28 | lazy_build => 1, | ||||
29 | ); | ||||
30 | |||||
31 | 1 | 5µs | 1 | 9.30ms | has all_isa_entry_classes => ( # spent 9.30ms making 1 call to Moose::has |
32 | isa => "ArrayRef[Str]", | ||||
33 | is => "ro", | ||||
34 | lazy_build => 1, | ||||
35 | ); | ||||
36 | |||||
37 | 1 | 4µs | 1 | 10.8ms | has includes => ( # spent 10.8ms making 1 call to Moose::has |
38 | isa => "ArrayRef[KiokuDB::TypeMap]", | ||||
39 | is => "ro", | ||||
40 | lazy_build => 1, | ||||
41 | ); | ||||
42 | |||||
43 | 9 | 19µs | # spent 12µs within KiokuDB::TypeMap::_build_includes which was called 9 times, avg 1µs/call:
# 9 times (12µs+0s) by KiokuDB::TypeMap::includes at line 11 of (eval 83)[Eval/Closure.pm:125], avg 1µs/call | ||
44 | |||||
45 | 1 | 600ns | my %loaded; | ||
46 | |||||
47 | # spent 2.64ms (826µs+1.82) within KiokuDB::TypeMap::resolve which was called 23 times, avg 115µs/call:
# 23 times (826µs+1.82ms) by KiokuDB::TypeMap::Shadow::resolve at line 20 of KiokuDB/TypeMap/Shadow.pm, avg 115µs/call | ||||
48 | 253 | 927µs | my ( $self, $class ) = @_; | ||
49 | |||||
50 | # if we're linking the class might not be loaded yet | ||||
51 | unless ( $loaded{$class}++ ) { | ||||
52 | 9 | 48µs | ( my $pmfile = $class . ".pm" ) =~ s{::}{/}g; # spent 48µs making 9 calls to KiokuDB::TypeMap::CORE:subst, avg 5µs/call | ||
53 | |||||
54 | # spent 310µs within KiokuDB::TypeMap::__ANON__[/Users/edenc/perl5/lib/perl5/KiokuDB/TypeMap.pm:56] which was called 9 times, avg 34µs/call:
# 9 times (310µs+0s) by Try::Tiny::try at line 76 of Try/Tiny.pm, avg 34µs/call | ||||
55 | 9 | 332µs | require $pmfile; | ||
56 | # spent 62µs (26+36) within KiokuDB::TypeMap::__ANON__[/Users/edenc/perl5/lib/perl5/KiokuDB/TypeMap.pm:58] which was called 2 times, avg 31µs/call:
# 2 times (26µs+36µs) by Try::Tiny::try at line 100 of Try/Tiny.pm, avg 31µs/call | ||||
57 | 2 | 64µs | 4 | 36µs | croak $_ unless /Can't locate \Q$pmfile\E in \@INC/; # spent 33µs making 2 calls to KiokuDB::TypeMap::CORE:regcomp, avg 16µs/call
# spent 3µs making 2 calls to KiokuDB::TypeMap::CORE:match, avg 1µs/call |
58 | 18 | 616µs | }; # spent 558µs making 9 calls to Try::Tiny::try, avg 62µs/call
# spent 58µs making 9 calls to Try::Tiny::catch, avg 6µs/call | ||
59 | } | ||||
60 | |||||
61 | # if this is an anonymous class, redo the lookup using a single named | ||||
62 | # ancestor | ||||
63 | 23 | 40µs | if ( my $meta = Class::MOP::get_metaclass_by_name($class) ) { # spent 40µs making 23 calls to Class::MOP::get_metaclass_by_name, avg 2µs/call | ||
64 | 16 | 266µs | if ( $meta->is_anon_class ) { # spent 266µs making 16 calls to Class::MOP::Class::is_anon_class, avg 17µs/call | ||
65 | my $ancestor = $meta; | ||||
66 | |||||
67 | search: { | ||||
68 | my @super = $ancestor->superclasses; | ||||
69 | |||||
70 | if ( @super == 1 ) { | ||||
71 | $ancestor = Class::MOP::get_metaclass_by_name($super[0]); | ||||
72 | if ( $ancestor->is_anon_class ) { | ||||
73 | redo search; | ||||
74 | } | ||||
75 | } else { | ||||
76 | croak "Cannot resolve anonymous class with multiple inheritence: $class"; | ||||
77 | } | ||||
78 | } | ||||
79 | |||||
80 | return $self->resolve( $ancestor->name ); | ||||
81 | } | ||||
82 | } | ||||
83 | |||||
84 | |||||
85 | 48 | 346µs | if ( my $entry = $self->all_entries->{$class} || $self->all_isa_entries->{$class} ) { # spent 159µs making 23 calls to KiokuDB::TypeMap::all_entries, avg 7µs/call
# spent 144µs making 21 calls to KiokuDB::TypeMap::all_isa_entries, avg 7µs/call
# spent 43µs making 4 calls to KiokuDB::TypeMap::resolve_entry, avg 11µs/call | ||
86 | return $self->resolve_entry( $entry ); | ||||
87 | } else { | ||||
88 | 19 | 320µs | foreach my $superclass ( @{ $self->all_isa_entry_classes } ) { # spent 320µs making 19 calls to KiokuDB::TypeMap::all_isa_entry_classes, avg 17µs/call | ||
89 | 89 | 180µs | if ( $class->isa($superclass) ) { # spent 180µs making 89 calls to UNIVERSAL::isa, avg 2µs/call | ||
90 | return $self->resolve_entry( $self->all_isa_entries->{$superclass} ); | ||||
91 | } | ||||
92 | } | ||||
93 | } | ||||
94 | |||||
95 | return; | ||||
96 | } | ||||
97 | |||||
98 | # spent 43µs (28+15) within KiokuDB::TypeMap::resolve_entry which was called 4 times, avg 11µs/call:
# 4 times (28µs+15µs) by KiokuDB::TypeMap::resolve at line 85, avg 11µs/call | ||||
99 | 12 | 46µs | my ( $self, $entry ) = @_; | ||
100 | |||||
101 | 4 | 15µs | if ( $entry->isa("KiokuDB::TypeMap::Entry::Alias") ) { # spent 15µs making 4 calls to UNIVERSAL::isa, avg 4µs/call | ||
102 | return $self->resolve( $entry->to ); | ||||
103 | } else { | ||||
104 | return $entry; | ||||
105 | } | ||||
106 | } | ||||
107 | |||||
108 | # spent 207ms (234µs+207) within KiokuDB::TypeMap::BUILD which was called 10 times, avg 20.7ms/call:
# 9 times (147µs+-18µs) by KiokuDB::TypeMap::new at line 66 of (eval 83)[Eval/Closure.pm:125], avg 14µs/call
# once (87µs+207ms) by KiokuDB::TypeMap::Default::JSON::new at line 161 of (eval 83)[Eval/Closure.pm:125] | ||||
109 | 111 | 183µs | my $self = shift; | ||
110 | |||||
111 | # verify that there are no conflicting internal definitions | ||||
112 | 10 | 100µs | my $reg = $self->entries; # spent 100µs making 10 calls to KiokuDB::TypeMap::entries, avg 10µs/call | ||
113 | 10 | 42µs | foreach my $key ( keys %{ $self->isa_entries } ) { # spent 42µs making 10 calls to KiokuDB::TypeMap::isa_entries, avg 4µs/call | ||
114 | if ( exists $reg->{$key} ) { | ||||
115 | croak "isa entry $key already present in plain entries"; | ||||
116 | } | ||||
117 | } | ||||
118 | |||||
119 | # Verify that there are no conflicts between the includesd type maps | ||||
120 | my %seen; | ||||
121 | 10 | 207ms | foreach my $map ( @{ $self->includes } ) { # spent 207ms making 10 calls to KiokuDB::TypeMap::includes, avg 20.7ms/call, recursion: max depth 1, sum of overlapping time 154µs | ||
122 | 7 | 127µs | foreach my $key ( keys %{ $map->all_entries } ) { # spent 127µs making 7 calls to KiokuDB::TypeMap::all_entries, avg 18µs/call | ||
123 | if ( $seen{$key} ) { | ||||
124 | croak "entry $key found in $map conflicts with $seen{$key}"; | ||||
125 | } | ||||
126 | |||||
127 | $seen{$key} = $map; | ||||
128 | } | ||||
129 | |||||
130 | 7 | 121µs | foreach my $key ( keys %{ $map->all_isa_entries } ) { # spent 121µs making 7 calls to KiokuDB::TypeMap::all_isa_entries, avg 17µs/call | ||
131 | if ( $seen{$key} ) { | ||||
132 | croak "isa entry $key found in $map conflicts with $seen{$key}"; | ||||
133 | } | ||||
134 | |||||
135 | $seen{$key} = $map; | ||||
136 | } | ||||
137 | } | ||||
138 | } | ||||
139 | |||||
140 | # spent 143µs (96+47) within KiokuDB::TypeMap::_build_all_entries which was called 10 times, avg 14µs/call:
# 10 times (96µs+47µs) by KiokuDB::TypeMap::all_entries at line 10 of (eval 83)[Eval/Closure.pm:125], avg 14µs/call | ||||
141 | 27 | 72µs | my $self = shift; | ||
142 | |||||
143 | return { | ||||
144 | 7 | 0s | map { %$_ } ( # spent 13µs making 7 calls to KiokuDB::TypeMap::all_entries, avg 2µs/call, recursion: max depth 1, sum of overlapping time 13µs | ||
145 | 20 | 34µs | ( map { $_->all_entries } @{ $self->includes } ), # spent 17µs making 10 calls to KiokuDB::TypeMap::entries, avg 2µs/call
# spent 16µs making 10 calls to KiokuDB::TypeMap::includes, avg 2µs/call | ||
146 | $self->entries, | ||||
147 | ), | ||||
148 | }; | ||||
149 | } | ||||
150 | |||||
151 | # spent 137µs (94+44) within KiokuDB::TypeMap::_build_all_isa_entries which was called 10 times, avg 14µs/call:
# 10 times (94µs+44µs) by KiokuDB::TypeMap::all_isa_entries at line 10 of (eval 83)[Eval/Closure.pm:125], avg 14µs/call | ||||
152 | 27 | 71µs | my $self = shift; | ||
153 | |||||
154 | return { | ||||
155 | 7 | 0s | map { %$_ } ( # spent 12µs making 7 calls to KiokuDB::TypeMap::all_isa_entries, avg 2µs/call, recursion: max depth 1, sum of overlapping time 12µs | ||
156 | 20 | 31µs | ( map { $_->all_isa_entries } @{ $self->includes } ), # spent 18µs making 10 calls to KiokuDB::TypeMap::isa_entries, avg 2µs/call
# spent 14µs making 10 calls to KiokuDB::TypeMap::includes, avg 1µs/call | ||
157 | $self->isa_entries, | ||||
158 | ), | ||||
159 | }; | ||||
160 | } | ||||
161 | |||||
162 | # spent 192µs (25+167) within KiokuDB::TypeMap::_build_all_isa_entry_classes which was called 3 times, avg 64µs/call:
# 3 times (25µs+167µs) by KiokuDB::TypeMap::all_isa_entry_classes at line 11 of (eval 83)[Eval/Closure.pm:125], avg 64µs/call | ||||
163 | 25 | 184µs | my $self = shift; | ||
164 | |||||
165 | return [ | ||||
166 | 38 | 40µs | sort { !$a->isa($b) <=> !$b->isa($a) } # least derived first # spent 40µs making 38 calls to UNIVERSAL::isa, avg 1µs/call | ||
167 | 6 | 167µs | keys %{ $self->all_isa_entries } # spent 162µs making 3 calls to KiokuDB::TypeMap::CORE:sort, avg 54µs/call
# spent 4µs making 3 calls to KiokuDB::TypeMap::all_isa_entries, avg 1µs/call | ||
168 | ]; | ||||
169 | } | ||||
170 | |||||
171 | 1 | 8µs | 2 | 10.4ms | __PACKAGE__->meta->make_immutable; # spent 10.4ms making 1 call to Class::MOP::Class::make_immutable
# spent 31µs making 1 call to KiokuDB::TypeMap::meta |
172 | |||||
173 | 1 | 43µs | __PACKAGE__ | ||
174 | |||||
175 | 1 | 28µs | 1 | 1.77ms | __END__ # spent 1.77ms making 1 call to B::Hooks::EndOfScope::__ANON__[B/Hooks/EndOfScope.pm:26] |
# spent 3µs within KiokuDB::TypeMap::CORE:match which was called 2 times, avg 1µs/call:
# 2 times (3µs+0s) by KiokuDB::TypeMap::__ANON__[/Users/edenc/perl5/lib/perl5/KiokuDB/TypeMap.pm:58] at line 57, avg 1µs/call | |||||
# spent 33µs within KiokuDB::TypeMap::CORE:regcomp which was called 2 times, avg 16µs/call:
# 2 times (33µs+0s) by KiokuDB::TypeMap::__ANON__[/Users/edenc/perl5/lib/perl5/KiokuDB/TypeMap.pm:58] at line 57, avg 16µs/call | |||||
# spent 162µs (122+40) within KiokuDB::TypeMap::CORE:sort which was called 3 times, avg 54µs/call:
# 3 times (122µs+40µs) by KiokuDB::TypeMap::_build_all_isa_entry_classes at line 167, avg 54µs/call | |||||
# spent 48µs within KiokuDB::TypeMap::CORE:subst which was called 9 times, avg 5µs/call:
# 9 times (48µs+0s) by KiokuDB::TypeMap::resolve at line 52, avg 5µs/call |