Filename | /home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/x86_64-linux/Mouse/Exporter.pm |
Statements | Executed 1182 statements in 4.64ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
25 | 21 | 19 | 1.37ms | 4.62ms | do_import | Mouse::Exporter::
5 | 1 | 1 | 1.03ms | 1.06ms | build_import_methods | Mouse::Exporter::
25 | 1 | 1 | 155µs | 155µs | _get_caller_package | Mouse::Exporter::
5 | 5 | 5 | 124µs | 1.27ms | setup_import_methods | Mouse::Exporter::
5 | 5 | 5 | 49µs | 49µs | import | Mouse::Exporter::
24 | 1 | 1 | 46µs | 46µs | CORE:subst (opcode) | Mouse::Exporter::
1 | 1 | 1 | 28µs | 34µs | BEGIN@2 | Mouse::Exporter::
1 | 1 | 1 | 15µs | 36µs | BEGIN@10 | Mouse::Exporter::
1 | 1 | 1 | 13µs | 36µs | BEGIN@231 | Mouse::Exporter::
1 | 1 | 1 | 12µs | 24µs | BEGIN@3 | Mouse::Exporter::
1 | 1 | 1 | 12µs | 35µs | BEGIN@96 | Mouse::Exporter::
1 | 1 | 1 | 10µs | 54µs | BEGIN@13 | Mouse::Exporter::
1 | 1 | 1 | 7µs | 7µs | BEGIN@5 | Mouse::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:43] | Mouse::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:47] | Mouse::Exporter::
0 | 0 | 0 | 0s | 0s | do_unimport | Mouse::Exporter::
0 | 0 | 0 | 0s | 0s | export | Mouse::Role::
0 | 0 | 0 | 0s | 0s | export_to_level | Mouse::Role::
0 | 0 | 0 | 0s | 0s | export | Mouse::Util::TypeConstraints::
0 | 0 | 0 | 0s | 0s | export_to_level | Mouse::Util::TypeConstraints::
0 | 0 | 0 | 0s | 0s | export | Mouse::
0 | 0 | 0 | 0s | 0s | export_to_level | Mouse::
0 | 0 | 0 | 0s | 0s | export | MouseX::StrictConstructor::
0 | 0 | 0 | 0s | 0s | export_to_level | MouseX::StrictConstructor::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Mouse::Exporter; | ||||
2 | 2 | 30µs | 2 | 40µs | # spent 34µs (28+6) within Mouse::Exporter::BEGIN@2 which was called:
# once (28µs+6µs) by Mouse::BEGIN@4 at line 2 # spent 34µs making 1 call to Mouse::Exporter::BEGIN@2
# spent 6µs making 1 call to strict::import |
3 | 2 | 26µs | 2 | 36µs | # spent 24µs (12+12) within Mouse::Exporter::BEGIN@3 which was called:
# once (12µs+12µs) by Mouse::BEGIN@4 at line 3 # spent 24µs making 1 call to Mouse::Exporter::BEGIN@3
# spent 12µs making 1 call to warnings::import |
4 | |||||
5 | 2 | 44µs | 1 | 7µs | # spent 7µs within Mouse::Exporter::BEGIN@5 which was called:
# once (7µs+0s) by Mouse::BEGIN@4 at line 5 # spent 7µs making 1 call to Mouse::Exporter::BEGIN@5 |
6 | |||||
7 | 1 | 1µs | my %SPEC; | ||
8 | |||||
9 | 1 | 1µs | my $strict_bits; | ||
10 | 1 | 36µs | 2 | 57µs | # spent 36µs (15+21) within Mouse::Exporter::BEGIN@10 which was called:
# once (15µs+21µs) by Mouse::BEGIN@4 at line 10 # spent 36µs making 1 call to Mouse::Exporter::BEGIN@10
# spent 21µs making 1 call to strict::bits |
11 | |||||
12 | 1 | 1µs | my $warnings_extra_bits; | ||
13 | 1 | 354µs | 2 | 97µs | # spent 54µs (10+44) within Mouse::Exporter::BEGIN@13 which was called:
# once (10µs+44µs) by Mouse::BEGIN@4 at line 13 # spent 54µs making 1 call to Mouse::Exporter::BEGIN@13
# spent 44µs making 1 call to warnings::bits |
14 | |||||
15 | # it must be "require", because Mouse::Util depends on Mouse::Exporter, | ||||
16 | # which depends on Mouse::Util::import() | ||||
17 | 1 | 118µs | require Mouse::Util; | ||
18 | |||||
19 | # spent 49µs within Mouse::Exporter::import which was called 5 times, avg 10µs/call:
# once (12µs+0s) by Mouse::Util::BEGIN@2 at line 2 of Mouse/Util.pm
# once (11µs+0s) by Mouse::Role::BEGIN@2 at line 2 of Mouse/Role.pm
# once (9µs+0s) by Mouse::BEGIN@4 at line 4 of Mouse.pm
# once (9µs+0s) by MouseX::StrictConstructor::BEGIN@5 at line 5 of MouseX/StrictConstructor.pm
# once (8µs+0s) by Mouse::Util::TypeConstraints::BEGIN@5 at line 5 of Mouse/Util/TypeConstraints.pm | ||||
20 | # strict->import; | ||||
21 | 5 | 9µs | $^H |= $strict_bits; | ||
22 | # warnings->import('all', FATAL => 'recursion'); | ||||
23 | 5 | 13µs | ${^WARNING_BITS} |= $warnings::Bits{all}; | ||
24 | 5 | 12µs | ${^WARNING_BITS} |= $warnings_extra_bits; | ||
25 | 5 | 32µs | return; | ||
26 | } | ||||
27 | |||||
28 | |||||
29 | # spent 1.27ms (124µs+1.15) within Mouse::Exporter::setup_import_methods which was called 5 times, avg 254µs/call:
# once (29µs+375µs) by Mouse::Util::BEGIN@20 at line 22 of Mouse/Util.pm
# once (30µs+254µs) by Any::Moose::_install_module at line 11 of Mouse/Role.pm
# once (24µs+246µs) by Mouse::BEGIN@18 at line 10 of Mouse/Util/TypeConstraints.pm
# once (21µs+209µs) by Hailo::BEGIN@11 at line 20 of Mouse.pm
# once (20µs+62µs) by Any::Moose::_install_module at line 9 of MouseX/StrictConstructor.pm | ||||
30 | 5 | 13µs | my($class, %args) = @_; | ||
31 | |||||
32 | 5 | 12µs | my $exporting_package = $args{exporting_package} ||= caller(); | ||
33 | |||||
34 | 5 | 28µs | 5 | 1.06ms | my($import, $unimport) = $class->build_import_methods(%args); # spent 1.06ms making 5 calls to Mouse::Exporter::build_import_methods, avg 211µs/call |
35 | |||||
36 | Mouse::Util::install_subroutines($exporting_package, | ||||
37 | import => $import, | ||||
38 | unimport => $unimport, | ||||
39 | |||||
40 | export_to_level => sub { | ||||
41 | my($package, $level, undef, @args) = @_; # the third argument is redundant | ||||
42 | $package->import({ into_level => $level + 1 }, @args); | ||||
43 | }, | ||||
44 | export => sub { | ||||
45 | my($package, $into, @args) = @_; | ||||
46 | $package->import({ into => $into }, @args); | ||||
47 | }, | ||||
48 | 5 | 101µs | 5 | 90µs | ); # spent 90µs making 5 calls to Mouse::Util::install_subroutines, avg 18µs/call |
49 | 5 | 25µs | return; | ||
50 | } | ||||
51 | |||||
52 | # spent 1.06ms (1.03+26µs) within Mouse::Exporter::build_import_methods which was called 5 times, avg 211µs/call:
# 5 times (1.03ms+26µs) by Mouse::Exporter::setup_import_methods at line 34, avg 211µs/call | ||||
53 | 5 | 10µs | my($self, %args) = @_; | ||
54 | |||||
55 | 5 | 8µs | my $exporting_package = $args{exporting_package} ||= caller(); | ||
56 | |||||
57 | 5 | 8µs | $SPEC{$exporting_package} = \%args; | ||
58 | |||||
59 | # canonicalize args | ||||
60 | 5 | 6µs | my @export_from; | ||
61 | 5 | 12µs | if($args{also}){ | ||
62 | my %seen; | ||||
63 | my @stack = ($exporting_package); | ||||
64 | |||||
65 | while(my $current = shift @stack){ | ||||
66 | push @export_from, $current; | ||||
67 | |||||
68 | my $also = $SPEC{$current}{also} or next; | ||||
69 | push @stack, grep{ !$seen{$_}++ } ref($also) ? @{ $also } : $also; | ||||
70 | } | ||||
71 | } | ||||
72 | else{ | ||||
73 | 5 | 8µs | @export_from = ($exporting_package); | ||
74 | } | ||||
75 | |||||
76 | 5 | 6µs | my %exports; | ||
77 | 5 | 5µs | my @removables; | ||
78 | 5 | 5µs | my @all; | ||
79 | |||||
80 | 5 | 5µs | my @init_meta_methods; | ||
81 | |||||
82 | 5 | 14µs | foreach my $package(@export_from){ | ||
83 | 5 | 7µs | my $spec = $SPEC{$package} or next; | ||
84 | |||||
85 | 5 | 13µs | if(my $as_is = $spec->{as_is}){ | ||
86 | 4 | 9µs | foreach my $thingy (@{$as_is}){ | ||
87 | 57 | 55µs | my($code_package, $code_name, $code); | ||
88 | |||||
89 | 57 | 119µs | if(ref($thingy)){ | ||
90 | 4 | 4µs | $code = $thingy; | ||
91 | 4 | 31µs | 4 | 9µs | ($code_package, $code_name) = Mouse::Util::get_code_info($code); # spent 9µs making 4 calls to Mouse::Util::get_code_info, avg 2µs/call |
92 | } | ||||
93 | else{ | ||||
94 | 53 | 54µs | $code_package = $package; | ||
95 | 53 | 51µs | $code_name = $thingy; | ||
96 | 2 | 675µs | 2 | 58µs | # spent 35µs (12+23) within Mouse::Exporter::BEGIN@96 which was called:
# once (12µs+23µs) by Mouse::BEGIN@4 at line 96 # spent 35µs making 1 call to Mouse::Exporter::BEGIN@96
# spent 23µs making 1 call to strict::unimport |
97 | 53 | 162µs | $code = \&{ $code_package . '::' . $code_name }; | ||
98 | } | ||||
99 | |||||
100 | 57 | 72µs | push @all, $code_name; | ||
101 | 57 | 73µs | $exports{$code_name} = $code; | ||
102 | 57 | 152µs | if($code_package eq $package){ | ||
103 | push @removables, $code_name; | ||||
104 | } | ||||
105 | } | ||||
106 | } | ||||
107 | |||||
108 | 5 | 77µs | 5 | 17µs | if(my $init_meta = $package->can('init_meta')){ # spent 17µs making 5 calls to UNIVERSAL::can, avg 3µs/call |
109 | if(!grep{ $_ == $init_meta } @init_meta_methods){ | ||||
110 | push @init_meta_methods, $init_meta; | ||||
111 | } | ||||
112 | } | ||||
113 | } | ||||
114 | 5 | 9µs | $args{EXPORTS} = \%exports; | ||
115 | 5 | 8µs | $args{REMOVABLES} = \@removables; | ||
116 | |||||
117 | 5 | 10µs | $args{groups}{all} ||= \@all; | ||
118 | |||||
119 | 5 | 14µs | if(my $default_list = $args{groups}{default}){ | ||
120 | 1 | 800ns | my %default; | ||
121 | 1 | 2µs | foreach my $keyword(@{$default_list}){ | ||
122 | $default{$keyword} = $exports{$keyword} | ||||
123 | || Carp::confess(qq{The $exporting_package package does not export "$keyword"}); | ||||
124 | } | ||||
125 | 1 | 2µs | $args{DEFAULT} = \%default; | ||
126 | } | ||||
127 | else{ | ||||
128 | 4 | 6µs | $args{groups}{default} ||= \@all; | ||
129 | 4 | 6µs | $args{DEFAULT} = $args{EXPORTS}; | ||
130 | } | ||||
131 | |||||
132 | 5 | 8µs | if(@init_meta_methods){ | ||
133 | $args{INIT_META} = \@init_meta_methods; | ||||
134 | } | ||||
135 | |||||
136 | 5 | 27µs | return (\&do_import, \&do_unimport); | ||
137 | } | ||||
138 | |||||
139 | |||||
140 | # the entity of general import() | ||||
141 | # spent 4.62ms (1.37+3.25) within Mouse::Exporter::do_import which was called 25 times, avg 185µs/call:
# 2 times (91µs+518µs) by Any::Moose::_install_module at line 2 of (eval 8)[Any/Moose.pm:152], avg 305µs/call
# 2 times (97µs+463µs) by Any::Moose::_install_module at line 2 of (eval 24)[Any/Moose.pm:152], avg 280µs/call
# 2 times (96µs+455µs) by Any::Moose::_install_module at line 2 of (eval 35)[Any/Moose.pm:152], avg 275µs/call
# 2 times (100µs+449µs) by Any::Moose::_install_module at line 2 of (eval 26)[Any/Moose.pm:152], avg 275µs/call
# once (69µs+507µs) by Any::Moose::_install_module at line 2 of (eval 32)[Any/Moose.pm:152]
# once (52µs+272µs) by Any::Moose::_install_module at line 2 of (eval 28)[Any/Moose.pm:152]
# once (54µs+139µs) by Any::Moose::_install_module at line 2 of (eval 50)[Any/Moose.pm:152]
# once (50µs+122µs) by Any::Moose::_install_module at line 2 of (eval 33)[Any/Moose.pm:152]
# once (48µs+111µs) by Any::Moose::_install_module at line 2 of (eval 29)[Any/Moose.pm:152]
# once (76µs+20µs) by Mouse::Object::BEGIN@2 at line 2 of Mouse/Object.pm
# once (71µs+25µs) by Mouse::Util::BEGIN@20 at line 65 of Mouse.pm
# once (70µs+16µs) by Mouse::Util::BEGIN@20 at line 67 of Mouse.pm
# once (63µs+23µs) by Mouse::Meta::Role::Application::BEGIN@2 at line 2 of Mouse/Meta/Role/Application.pm
# once (70µs+16µs) by Mouse::Meta::TypeConstraint::BEGIN@2 at line 2 of Mouse/Meta/TypeConstraint.pm
# once (61µs+20µs) by Mouse::Meta::Role::BEGIN@2 at line 2 of Mouse/Meta/Role.pm
# once (59µs+21µs) by Mouse::Meta::Attribute::BEGIN@2 at line 2 of Mouse/Meta/Attribute.pm
# once (60µs+18µs) by Mouse::Meta::Module::BEGIN@2 at line 2 of Mouse/Meta/Module.pm
# once (58µs+17µs) by Mouse::Meta::Class::BEGIN@2 at line 2 of Mouse/Meta/Class.pm
# once (53µs+15µs) by Mouse::Util::BEGIN@20 at line 66 of Mouse.pm
# once (44µs+11µs) by Mouse::Meta::Role::Composite::BEGIN@2 at line 2 of Mouse/Meta/Role/Composite.pm
# once (32µs+9µs) by Mouse::Util::TypeConstraints::BEGIN@2 at line 2 of Mouse/Util/TypeConstraints.pm | ||||
142 | 25 | 51µs | my($package, @args) = @_; | ||
143 | |||||
144 | 25 | 63µs | my $spec = $SPEC{$package} | ||
145 | || Carp::confess("The package $package package does not use Mouse::Exporter"); | ||||
146 | |||||
147 | 25 | 111µs | 25 | 155µs | my $into = _get_caller_package(ref($args[0]) ? shift @args : undef); # spent 155µs making 25 calls to Mouse::Exporter::_get_caller_package, avg 6µs/call |
148 | |||||
149 | 25 | 27µs | my @exports; | ||
150 | 25 | 22µs | my @traits; | ||
151 | |||||
152 | 25 | 63µs | while(@args){ | ||
153 | 12 | 16µs | my $arg = shift @args; | ||
154 | 12 | 142µs | 24 | 46µs | if($arg =~ s/^-//){ # spent 46µs making 24 calls to Mouse::Exporter::CORE:subst, avg 2µs/call |
155 | if($arg eq 'traits'){ | ||||
156 | push @traits, ref($args[0]) ? @{shift(@args)} : shift(@args); | ||||
157 | } | ||||
158 | else { | ||||
159 | Mouse::Util::not_supported("-$arg"); | ||||
160 | } | ||||
161 | } | ||||
162 | elsif($arg =~ s/^://){ | ||||
163 | 9 | 16µs | my $group = $spec->{groups}{$arg} | ||
164 | || Carp::confess(qq{The $package package does not export the group "$arg"}); | ||||
165 | 9 | 22µs | push @exports, @{$group}; | ||
166 | } | ||||
167 | else{ | ||||
168 | 3 | 4µs | push @exports, $arg; | ||
169 | } | ||||
170 | } | ||||
171 | |||||
172 | # strict->import; | ||||
173 | 25 | 47µs | $^H |= $strict_bits; | ||
174 | # warnings->import('all', FATAL => 'recursion'); | ||||
175 | 25 | 75µs | ${^WARNING_BITS} |= $warnings::Bits{all}; | ||
176 | 25 | 56µs | ${^WARNING_BITS} |= $warnings_extra_bits; | ||
177 | |||||
178 | 25 | 64µs | if($spec->{INIT_META}){ | ||
179 | 13 | 14µs | my $meta; | ||
180 | 13 | 48µs | foreach my $init_meta(@{$spec->{INIT_META}}){ | ||
181 | 13 | 83µs | 13 | 2.76ms | $meta = $package->$init_meta(for_class => $into); # spent 1.87ms making 5 calls to Mouse::init_meta, avg 374µs/call
# spent 539µs making 4 calls to Mouse::Role::init_meta, avg 135µs/call
# spent 354µs making 4 calls to MouseX::StrictConstructor::init_meta, avg 88µs/call |
182 | } | ||||
183 | |||||
184 | 13 | 18µs | if(@traits){ | ||
185 | my $type = (split /::/, ref $meta)[-1]; # e.g. "Class" for "My::Meta::Class" | ||||
186 | @traits = | ||||
187 | map{ | ||||
188 | ref($_) ? $_ | ||||
189 | : Mouse::Util::resolve_metaclass_alias($type => $_, trait => 1) | ||||
190 | } @traits; | ||||
191 | |||||
192 | require Mouse::Util::MetaRole; | ||||
193 | Mouse::Util::MetaRole::apply_metaroles( | ||||
194 | for => $into, | ||||
195 | Mouse::Util::is_a_metarole($into->meta) | ||||
196 | ? (role_metaroles => { role => \@traits }) | ||||
197 | : (class_metaroles => { class => \@traits }), | ||||
198 | ); | ||||
199 | } | ||||
200 | } | ||||
201 | elsif(@traits){ | ||||
202 | Carp::confess("Cannot provide traits when $package does not have an init_meta() method"); | ||||
203 | } | ||||
204 | |||||
205 | 25 | 62µs | if(@exports){ | ||
206 | 10 | 11µs | my @export_table; | ||
207 | 10 | 26µs | foreach my $keyword(@exports){ | ||
208 | 39 | 101µs | push @export_table, | ||
209 | $keyword => ($spec->{EXPORTS}{$keyword} | ||||
210 | || Carp::confess(qq{The $package package does not export "$keyword"}) | ||||
211 | ); | ||||
212 | } | ||||
213 | 10 | 134µs | 10 | 87µs | Mouse::Util::install_subroutines($into, @export_table); # spent 87µs making 10 calls to Mouse::Util::install_subroutines, avg 9µs/call |
214 | } | ||||
215 | else{ | ||||
216 | 15 | 289µs | 15 | 195µs | Mouse::Util::install_subroutines($into, %{$spec->{DEFAULT}}); # spent 195µs making 15 calls to Mouse::Util::install_subroutines, avg 13µs/call |
217 | } | ||||
218 | 25 | 137µs | return; | ||
219 | } | ||||
220 | |||||
221 | # the entity of general unimport() | ||||
222 | sub do_unimport { | ||||
223 | my($package, $arg) = @_; | ||||
224 | |||||
225 | my $spec = $SPEC{$package} | ||||
226 | || Carp::confess("The package $package does not use Mouse::Exporter"); | ||||
227 | |||||
228 | my $from = _get_caller_package($arg); | ||||
229 | |||||
230 | my $stash = do{ | ||||
231 | 2 | 150µs | 2 | 59µs | # spent 36µs (13+23) within Mouse::Exporter::BEGIN@231 which was called:
# once (13µs+23µs) by Mouse::BEGIN@4 at line 231 # spent 36µs making 1 call to Mouse::Exporter::BEGIN@231
# spent 23µs making 1 call to strict::unimport |
232 | \%{$from . '::'} | ||||
233 | }; | ||||
234 | |||||
235 | for my $keyword (@{ $spec->{REMOVABLES} }) { | ||||
236 | next if !exists $stash->{$keyword}; | ||||
237 | my $gv = \$stash->{$keyword}; | ||||
238 | if(ref($gv) eq 'GLOB' && *{$gv}{CODE} == $spec->{EXPORTS}{$keyword}){ # make sure it is from us | ||||
239 | delete $stash->{$keyword}; | ||||
240 | } | ||||
241 | } | ||||
242 | return; | ||||
243 | } | ||||
244 | |||||
245 | # spent 155µs within Mouse::Exporter::_get_caller_package which was called 25 times, avg 6µs/call:
# 25 times (155µs+0s) by Mouse::Exporter::do_import at line 147, avg 6µs/call | ||||
246 | 25 | 32µs | my($arg) = @_; | ||
247 | |||||
248 | # We need one extra level because it's called by import so there's a layer | ||||
249 | # of indirection | ||||
250 | 25 | 42µs | if(ref $arg){ | ||
251 | return defined($arg->{into}) ? $arg->{into} | ||||
252 | : defined($arg->{into_level}) ? scalar caller(1 + $arg->{into_level}) | ||||
253 | : scalar caller(1); | ||||
254 | } | ||||
255 | else{ | ||||
256 | 22 | 122µs | return scalar caller(1); | ||
257 | } | ||||
258 | } | ||||
259 | |||||
260 | #sub _spec{ %SPEC } | ||||
261 | |||||
262 | 1 | 4µs | 1; | ||
263 | __END__ | ||||
# spent 46µs within Mouse::Exporter::CORE:subst which was called 24 times, avg 2µs/call:
# 24 times (46µs+0s) by Mouse::Exporter::do_import at line 154, avg 2µs/call |