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