← Index
NYTProf Performance Profile   « block view • line view • sub view »
For reply.pl
  Run on Thu Oct 21 22:40:13 2010
Reported on Thu Oct 21 22:44:42 2010

Filename/home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/x86_64-linux/Mouse/Exporter.pm
StatementsExecuted 1182 statements in 4.64ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
2521191.37ms4.62msMouse::Exporter::::do_import Mouse::Exporter::do_import
5111.03ms1.06msMouse::Exporter::::build_import_methods Mouse::Exporter::build_import_methods
2511155µs155µsMouse::Exporter::::_get_caller_package Mouse::Exporter::_get_caller_package
555124µs1.27msMouse::Exporter::::setup_import_methods Mouse::Exporter::setup_import_methods
55549µs49µsMouse::Exporter::::import Mouse::Exporter::import
241146µs46µsMouse::Exporter::::CORE:subst Mouse::Exporter::CORE:subst (opcode)
11128µs34µsMouse::Exporter::::BEGIN@2 Mouse::Exporter::BEGIN@2
11115µs36µsMouse::Exporter::::BEGIN@10 Mouse::Exporter::BEGIN@10
11113µs36µsMouse::Exporter::::BEGIN@231 Mouse::Exporter::BEGIN@231
11112µs24µsMouse::Exporter::::BEGIN@3 Mouse::Exporter::BEGIN@3
11112µs35µsMouse::Exporter::::BEGIN@96 Mouse::Exporter::BEGIN@96
11110µs54µsMouse::Exporter::::BEGIN@13 Mouse::Exporter::BEGIN@13
1117µs7µsMouse::Exporter::::BEGIN@5 Mouse::Exporter::BEGIN@5
0000s0sMouse::Exporter::::__ANON__[:43] Mouse::Exporter::__ANON__[:43]
0000s0sMouse::Exporter::::__ANON__[:47] Mouse::Exporter::__ANON__[:47]
0000s0sMouse::Exporter::::do_unimport Mouse::Exporter::do_unimport
0000s0sMouse::Role::::export Mouse::Role::export
0000s0sMouse::Role::::export_to_level Mouse::Role::export_to_level
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
0000s0sMouseX::StrictConstructor::::export MouseX::StrictConstructor::export
0000s0sMouseX::StrictConstructor::::export_to_level MouseX::StrictConstructor::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;
2230µs240µ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
use strict;
# spent 34µs making 1 call to Mouse::Exporter::BEGIN@2 # spent 6µs making 1 call to strict::import
3226µs236µ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
use warnings;
# spent 24µs making 1 call to Mouse::Exporter::BEGIN@3 # spent 12µs making 1 call to warnings::import
4
5244µs17µs
# spent 7µs within Mouse::Exporter::BEGIN@5 which was called: # once (7µs+0s) by Mouse::BEGIN@4 at line 5
use Carp ();
# spent 7µs making 1 call to Mouse::Exporter::BEGIN@5
6
711µsmy %SPEC;
8
911µsmy $strict_bits;
10136µs257µ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
BEGIN{ $strict_bits = strict::bits(qw(subs refs vars)); }
# spent 36µs making 1 call to Mouse::Exporter::BEGIN@10 # spent 21µs making 1 call to strict::bits
11
1211µsmy $warnings_extra_bits;
131354µs297µ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
BEGIN{ $warnings_extra_bits = warnings::bits(FATAL => 'recursion') }
# 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()
171118µsrequire 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
sub import{
20 # strict->import;
2159µs $^H |= $strict_bits;
22 # warnings->import('all', FATAL => 'recursion');
23513µs ${^WARNING_BITS} |= $warnings::Bits{all};
24512µs ${^WARNING_BITS} |= $warnings_extra_bits;
25532µ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
sub setup_import_methods{
30513µs my($class, %args) = @_;
31
32512µs my $exporting_package = $args{exporting_package} ||= caller();
33
34528µs51.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 },
485101µs590µs );
# spent 90µs making 5 calls to Mouse::Util::install_subroutines, avg 18µs/call
49525µ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
sub build_import_methods{
53510µs my($self, %args) = @_;
54
5558µs my $exporting_package = $args{exporting_package} ||= caller();
56
5758µs $SPEC{$exporting_package} = \%args;
58
59 # canonicalize args
6056µs my @export_from;
61512µ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{
7358µs @export_from = ($exporting_package);
74 }
75
7656µs my %exports;
7755µs my @removables;
7855µs my @all;
79
8055µs my @init_meta_methods;
81
82514µs foreach my $package(@export_from){
8357µs my $spec = $SPEC{$package} or next;
84
85513µs if(my $as_is = $spec->{as_is}){
8649µs foreach my $thingy (@{$as_is}){
875755µs my($code_package, $code_name, $code);
88
8957119µs if(ref($thingy)){
9044µs $code = $thingy;
91431µs49µ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{
945354µs $code_package = $package;
955351µs $code_name = $thingy;
962675µs258µ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
no strict 'refs';
# spent 35µs making 1 call to Mouse::Exporter::BEGIN@96 # spent 23µs making 1 call to strict::unimport
9753162µs $code = \&{ $code_package . '::' . $code_name };
98 }
99
1005772µs push @all, $code_name;
1015773µs $exports{$code_name} = $code;
10257152µs if($code_package eq $package){
103 push @removables, $code_name;
104 }
105 }
106 }
107
108577µs517µ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 }
11459µs $args{EXPORTS} = \%exports;
11558µs $args{REMOVABLES} = \@removables;
116
117510µs $args{groups}{all} ||= \@all;
118
119514µs if(my $default_list = $args{groups}{default}){
1201800ns my %default;
12112µs foreach my $keyword(@{$default_list}){
122 $default{$keyword} = $exports{$keyword}
123 || Carp::confess(qq{The $exporting_package package does not export "$keyword"});
124 }
12512µs $args{DEFAULT} = \%default;
126 }
127 else{
12846µs $args{groups}{default} ||= \@all;
12946µs $args{DEFAULT} = $args{EXPORTS};
130 }
131
13258µs if(@init_meta_methods){
133 $args{INIT_META} = \@init_meta_methods;
134 }
135
136527µ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
sub do_import {
1422551µs my($package, @args) = @_;
143
1442563µs my $spec = $SPEC{$package}
145 || Carp::confess("The package $package package does not use Mouse::Exporter");
146
14725111µs25155µ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
1492527µs my @exports;
1502522µs my @traits;
151
1522563µs while(@args){
1531216µs my $arg = shift @args;
15412142µs2446µ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/^://){
163916µs my $group = $spec->{groups}{$arg}
164 || Carp::confess(qq{The $package package does not export the group "$arg"});
165922µs push @exports, @{$group};
166 }
167 else{
16834µs push @exports, $arg;
169 }
170 }
171
172 # strict->import;
1732547µs $^H |= $strict_bits;
174 # warnings->import('all', FATAL => 'recursion');
1752575µs ${^WARNING_BITS} |= $warnings::Bits{all};
1762556µs ${^WARNING_BITS} |= $warnings_extra_bits;
177
1782564µs if($spec->{INIT_META}){
1791314µs my $meta;
1801348µs foreach my $init_meta(@{$spec->{INIT_META}}){
1811383µs132.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
1841318µ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
2052562µs if(@exports){
2061011µs my @export_table;
2071026µs foreach my $keyword(@exports){
20839101µs push @export_table,
209 $keyword => ($spec->{EXPORTS}{$keyword}
210 || Carp::confess(qq{The $package package does not export "$keyword"})
211 );
212 }
21310134µs1087µ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{
21615289µs15195µs Mouse::Util::install_subroutines($into, %{$spec->{DEFAULT}});
# spent 195µs making 15 calls to Mouse::Util::install_subroutines, avg 13µs/call
217 }
21825137µs return;
219}
220
221# the entity of general unimport()
222sub 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{
2312150µs259µ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
no strict 'refs';
# 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
sub _get_caller_package {
2462532µs my($arg) = @_;
247
248 # We need one extra level because it's called by import so there's a layer
249 # of indirection
2502542µ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{
25622122µs return scalar caller(1);
257 }
258}
259
260#sub _spec{ %SPEC }
261
26214µs1;
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
sub Mouse::Exporter::CORE:subst; # opcode