← Index
NYTProf Performance Profile   « line view »
For fastest.pl
  Run on Fri Jan 31 20:48:16 2014
Reported on Fri Jan 31 20:49:40 2014

Filename/opt/perl-5.18.1/lib/site_perl/5.18.1/darwin-thread-multi-2level/Mouse/Exporter.pm
StatementsExecuted 735 statements in 2.70ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11119363µs760µsMouse::Exporter::::do_import Mouse::Exporter::do_import
311292µs308µsMouse::Exporter::::build_import_methods Mouse::Exporter::build_import_methods
33369µs430µsMouse::Exporter::::setup_import_methods Mouse::Exporter::setup_import_methods
221131µs31µsMouse::Exporter::::CORE:subst Mouse::Exporter::CORE:subst (opcode)
111129µs29µsMouse::Exporter::::_get_caller_package Mouse::Exporter::_get_caller_package
33317µs17µsMouse::Exporter::::import Mouse::Exporter::import
11116µs37µsMouse::Exporter::::BEGIN@2 Mouse::Exporter::BEGIN@2
11113µs38µsMouse::Exporter::::BEGIN@10 Mouse::Exporter::BEGIN@10
11110µs24µsMouse::Exporter::::BEGIN@232 Mouse::Exporter::BEGIN@232
1119µs23µsMouse::Exporter::::BEGIN@98 Mouse::Exporter::BEGIN@98
1119µs14µsMouse::Exporter::::BEGIN@3 Mouse::Exporter::BEGIN@3
1114µs4µsMouse::Exporter::::BEGIN@4 Mouse::Exporter::BEGIN@4
0000s0sMouse::Exporter::::__ANON__[:45] Mouse::Exporter::__ANON__[:45]
0000s0sMouse::Exporter::::__ANON__[:49] Mouse::Exporter::__ANON__[:49]
0000s0sMouse::Exporter::::do_unimport Mouse::Exporter::do_unimport
0000s0sMouse::Util::TypeConstraints::::exportMouse::Util::TypeConstraints::export
0000s0sMouse::Util::TypeConstraints::::export_to_levelMouse::Util::TypeConstraints::export_to_level
0000s0sMouse::::export Mouse::export
0000s0sMouse::::export_to_level Mouse::export_to_level
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Mouse::Exporter;
2234µs258µ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
use strict;
# spent 37µs making 1 call to Mouse::Exporter::BEGIN@2 # spent 20µs making 1 call to strict::import
3236µs218µ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
use warnings;
# spent 14µs making 1 call to Mouse::Exporter::BEGIN@3 # spent 5µs making 1 call to warnings::import
4279µs14µs
# spent 4µs within Mouse::Exporter::BEGIN@4 which was called: # once (4µs+0s) by Mouse::BEGIN@4 at line 4
use Carp ();
# spent 4µs making 1 call to Mouse::Exporter::BEGIN@4
5
61200nsmy %SPEC;
7
81100nsmy $strict_bits;
910smy $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
BEGIN{
1111µs110µs $strict_bits = strict::bits(qw(subs refs vars));
# spent 10µs making 1 call to strict::bits
1215µs115µs $warnings_extra_bits = warnings::bits(FATAL => 'recursion');
# spent 15µs making 1 call to warnings::bits
131472µs138µ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()
17183µsrequire 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
sub import{
20 ## no critic ProhibitBitwiseOperators
21
22 # strict->import;
2333µs $^H |= $strict_bits;
24 # warnings->import('all', FATAL => 'recursion');
2535µs ${^WARNING_BITS} |= $warnings::Bits{all};
2634µs ${^WARNING_BITS} |= $warnings_extra_bits;
27316µ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
sub setup_import_methods{
3235µs my($class, %args) = @_;
33
3435µs my $exporting_package = $args{exporting_package} ||= caller();
35
36310µs3308µ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 },
50358µs352µs );
# spent 52µs making 3 calls to Mouse::Util::install_subroutines, avg 17µs/call
51314µ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
sub build_import_methods{
5533µs my($self, %args) = @_;
56
5731µs my $exporting_package = $args{exporting_package} ||= caller();
58
5933µs $SPEC{$exporting_package} = \%args;
60
61 # canonicalize args
623300ns my @export_from;
6332µ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{
7532µs @export_from = ($exporting_package);
76 }
77
783400ns my %exports;
793300ns my @removables;
8030s my @all;
81
823200ns my @init_meta_methods;
83
8432µs foreach my $package(@export_from){
8531µs my $spec = $SPEC{$package} or next;
86
8733µs if(my $as_is = $spec->{as_is}){
8832µs foreach my $thingy (@{$as_is}){
8944500ns my($code_package, $code_name, $code);
90
914410µs if(ref($thingy)){
922200ns $code = $thingy;
93217µs25µ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{
96424µs $code_package = $package;
97425µs $code_name = $thingy;
982891µs237µ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
no strict 'refs';
# spent 23µs making 1 call to Mouse::Exporter::BEGIN@98 # spent 14µs making 1 call to strict::unimport
994263µs $code = \&{ $code_package . '::' . $code_name };
100 }
101
1024422µs push @all, $code_name;
1034417µs $exports{$code_name} = $code;
1044435µs if($code_package eq $package){
105 push @removables, $code_name;
106 }
107 }
108 }
109
110343µs311µ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 }
11632µs $args{EXPORTS} = \%exports;
11732µs $args{REMOVABLES} = \@removables;
118
11933µs $args{groups}{all} ||= \@all;
120
12132µs if(my $default_list = $args{groups}{default}){
1221100ns my %default;
1231400ns foreach my $keyword(@{$default_list}){
124 $default{$keyword} = $exports{$keyword}
125 || Carp::confess(qq{The $exporting_package package does not export "$keyword"});
126 }
1271600ns $args{DEFAULT} = \%default;
128 }
129 else{
13021µs $args{groups}{default} ||= \@all;
1312700ns $args{DEFAULT} = $args{EXPORTS};
132 }
133
13431µs if(@init_meta_methods){
135 $args{INIT_META} = \@init_meta_methods;
136 }
137
138320µ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
sub do_import {
1431113µs my($package, @args) = @_;
144
145119µs my $spec = $SPEC{$package}
146 || Carp::confess("The package $package package does not use Mouse::Exporter");
147
1481119µs1129µ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
150111µs my @exports;
151110s my @traits;
152
153116µs while(@args){
154115µs my $arg = shift @args;
1551176µs2231µ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/^://){
16486µs my $group = $spec->{groups}{$arg}
165 || Carp::confess(qq{The $package package does not export the group "$arg"});
166813µs push @exports, @{$group};
167 }
168 else{
16932µs push @exports, $arg;
170 }
171 }
172
173 # strict->import;
1741110µs $^H |= $strict_bits; ## no critic ProhibitBitwiseOperators
175 # warnings->import('all', FATAL => 'recursion');
1761118µs ${^WARNING_BITS} |= $warnings::Bits{all}; ## no critic ProhibitBitwiseOperators
1771113µs ${^WARNING_BITS} |= $warnings_extra_bits; ## no critic ProhibitBitwiseOperators
178
179115µs if($spec->{INIT_META}){
1801100ns my $meta;
18111µs foreach my $init_meta(@{$spec->{INIT_META}}){
18212µs1255µs $meta = $package->$init_meta(for_class => $into);
# spent 255µs making 1 call to Mouse::init_meta
183 }
184
1851400ns 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
206114µs if(@exports){
2079600ns my @export_table;
20897µs foreach my $keyword(@exports){
2093531µs push @export_table,
210 $keyword => ($spec->{EXPORTS}{$keyword}
211 || Carp::confess(qq{The $package package does not export "$keyword"})
212 );
213 }
2149101µs966µ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{
217234µs216µs Mouse::Util::install_subroutines($into, %{$spec->{DEFAULT}});
# spent 16µs making 2 calls to Mouse::Util::install_subroutines, avg 8µs/call
218 }
2191152µs return;
220}
221
222# the entity of general unimport()
223sub 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{
2322216µs239µ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
no strict 'refs';
# 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
sub _get_caller_package {
249112µs my($arg) = @_;
250
251 # We need one extra level because it's called by import so there's a layer
252 # of indirection
2531113µ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{
259846µs return scalar caller(1);
260 }
261}
262
26314µs1;
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
sub Mouse::Exporter::CORE:subst; # opcode