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