← Index
NYTProf Performance Profile   « block view • line view • sub view »
For bin/hailo
  Run on Thu Oct 21 22:50:37 2010
Reported on Thu Oct 21 22:52:04 2010

Filename/home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/x86_64-linux/Mouse/Exporter.pm
StatementsExecuted 1944 statements in 8.31ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
4035302.02ms8.57msMouse::Exporter::::do_import Mouse::Exporter::do_import
1111.82ms1.93msMouse::Exporter::::BEGIN@5 Mouse::Exporter::BEGIN@5
5111.01ms1.03msMouse::Exporter::::build_import_methods Mouse::Exporter::build_import_methods
11119835µs899µsMouse::Exporter::::do_unimport Mouse::Exporter::do_unimport
5121302µs302µsMouse::Exporter::::_get_caller_package Mouse::Exporter::_get_caller_package
555125µs1.25msMouse::Exporter::::setup_import_methods Mouse::Exporter::setup_import_methods
55554µs54µsMouse::Exporter::::import Mouse::Exporter::import
301151µs51µsMouse::Exporter::::CORE:subst Mouse::Exporter::CORE:subst (opcode)
11127µs34µsMouse::Exporter::::BEGIN@2 Mouse::Exporter::BEGIN@2
11116µs32µsMouse::Exporter::::BEGIN@3 Mouse::Exporter::BEGIN@3
11113µs38µsMouse::Exporter::::BEGIN@231 Mouse::Exporter::BEGIN@231
11112µs35µsMouse::Exporter::::BEGIN@96 Mouse::Exporter::BEGIN@96
11111µs30µsMouse::Exporter::::BEGIN@10 Mouse::Exporter::BEGIN@10
11110µs52µsMouse::Exporter::::BEGIN@13 Mouse::Exporter::BEGIN@13
0000s0sMouse::Exporter::::__ANON__[:43] Mouse::Exporter::__ANON__[:43]
0000s0sMouse::Exporter::::__ANON__[:47] Mouse::Exporter::__ANON__[:47]
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;
2229µs241µs
# spent 34µs (27+7) within Mouse::Exporter::BEGIN@2 which was called: # once (27µs+7µs) by Mouse::BEGIN@4 at line 2
use strict;
# spent 34µs making 1 call to Mouse::Exporter::BEGIN@2 # spent 7µs making 1 call to strict::import
3234µs247µs
# spent 32µs (16+15) within Mouse::Exporter::BEGIN@3 which was called: # once (16µs+15µs) by Mouse::BEGIN@4 at line 3
use warnings;
# spent 32µs making 1 call to Mouse::Exporter::BEGIN@3 # spent 15µs making 1 call to warnings::import
4
521.78ms11.93ms
# spent 1.93ms (1.82+119µs) within Mouse::Exporter::BEGIN@5 which was called: # once (1.82ms+119µs) by Mouse::BEGIN@4 at line 5
use Carp ();
# spent 1.93ms making 1 call to Mouse::Exporter::BEGIN@5
6
71800nsmy %SPEC;
8
91600nsmy $strict_bits;
10136µs250µs
# spent 30µs (11+19) within Mouse::Exporter::BEGIN@10 which was called: # once (11µs+19µs) by Mouse::BEGIN@4 at line 10
BEGIN{ $strict_bits = strict::bits(qw(subs refs vars)); }
# spent 30µs making 1 call to Mouse::Exporter::BEGIN@10 # spent 19µs making 1 call to strict::bits
11
1211µsmy $warnings_extra_bits;
131339µs293µs
# spent 52µs (10+41) within Mouse::Exporter::BEGIN@13 which was called: # once (10µs+41µs) by Mouse::BEGIN@4 at line 13
BEGIN{ $warnings_extra_bits = warnings::bits(FATAL => 'recursion') }
# spent 52µs making 1 call to Mouse::Exporter::BEGIN@13 # spent 41µ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()
171124µsrequire Mouse::Util;
18
19
# spent 54µs within Mouse::Exporter::import which was called 5 times, avg 11µs/call: # once (13µs+0s) by Mouse::Util::BEGIN@2 at line 2 of Mouse/Util.pm # once (12µs+0s) by MouseX::StrictConstructor::BEGIN@5 at line 5 of MouseX/StrictConstructor.pm # once (10µs+0s) by Mouse::BEGIN@4 at line 4 of Mouse.pm # once (10µs+0s) by Mouse::Role::BEGIN@2 at line 2 of Mouse/Role.pm # once (9µs+0s) by Mouse::Util::TypeConstraints::BEGIN@5 at line 5 of Mouse/Util/TypeConstraints.pm
sub import{
20 # strict->import;
212065µs $^H |= $strict_bits;
22 # warnings->import('all', FATAL => 'recursion');
23 ${^WARNING_BITS} |= $warnings::Bits{all};
24 ${^WARNING_BITS} |= $warnings_extra_bits;
25 return;
26}
27
28
29
# spent 1.25ms (125µs+1.12) within Mouse::Exporter::setup_import_methods which was called 5 times, avg 250µs/call: # once (29µs+375µs) by Mouse::Util::BEGIN@20 at line 22 of Mouse/Util.pm # once (26µs+254µs) by Mouse::BEGIN@18 at line 10 of Mouse/Util/TypeConstraints.pm # once (23µs+222µs) by MouseX::Getopt::BEGIN@10 at line 11 of Mouse/Role.pm # once (22µs+204µs) by hailo::BEGIN@6 at line 20 of Mouse.pm # once (25µs+69µs) by Any::Moose::_install_module at line 9 of MouseX/StrictConstructor.pm
sub setup_import_methods{
3025175µs my($class, %args) = @_;
31
32 my $exporting_package = $args{exporting_package} ||= caller();
33
3451.03ms my($import, $unimport) = $class->build_import_methods(%args);
# spent 1.03ms making 5 calls to Mouse::Exporter::build_import_methods, avg 207µ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 },
48590µs );
# spent 90µs making 5 calls to Mouse::Util::install_subroutines, avg 18µs/call
49 return;
50}
51
52
# spent 1.03ms (1.01+25µs) within Mouse::Exporter::build_import_methods which was called 5 times, avg 207µs/call: # 5 times (1.01ms+25µs) by Mouse::Exporter::setup_import_methods at line 34, avg 207µs/call
sub build_import_methods{
535671.04ms my($self, %args) = @_;
54
55 my $exporting_package = $args{exporting_package} ||= caller();
56
57 $SPEC{$exporting_package} = \%args;
58
59 # canonicalize args
60 my @export_from;
61 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 @export_from = ($exporting_package);
74 }
75
76 my %exports;
77 my @removables;
78 my @all;
79
80 my @init_meta_methods;
81
82 foreach my $package(@export_from){
83 my $spec = $SPEC{$package} or next;
84
85 if(my $as_is = $spec->{as_is}){
86 foreach my $thingy (@{$as_is}){
87 my($code_package, $code_name, $code);
88
89 if(ref($thingy)){
90 $code = $thingy;
9149µ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 $code_package = $package;
95 $code_name = $thingy;
962680µs259µs
# spent 35µs (12+24) within Mouse::Exporter::BEGIN@96 which was called: # once (12µs+24µs) by Mouse::BEGIN@4 at line 96
no strict 'refs';
# spent 35µs making 1 call to Mouse::Exporter::BEGIN@96 # spent 24µs making 1 call to strict::unimport
97 $code = \&{ $code_package . '::' . $code_name };
98 }
99
100 push @all, $code_name;
101 $exports{$code_name} = $code;
102 if($code_package eq $package){
103 push @removables, $code_name;
104 }
105 }
106 }
107
108516µs if(my $init_meta = $package->can('init_meta')){
# spent 16µ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 $args{EXPORTS} = \%exports;
115 $args{REMOVABLES} = \@removables;
116
117 $args{groups}{all} ||= \@all;
118
119 if(my $default_list = $args{groups}{default}){
120 my %default;
121 foreach my $keyword(@{$default_list}){
122 $default{$keyword} = $exports{$keyword}
123 || Carp::confess(qq{The $exporting_package package does not export "$keyword"});
124 }
125 $args{DEFAULT} = \%default;
126 }
127 else{
128 $args{groups}{default} ||= \@all;
129 $args{DEFAULT} = $args{EXPORTS};
130 }
131
132 if(@init_meta_methods){
133 $args{INIT_META} = \@init_meta_methods;
134 }
135
136 return (\&do_import, \&do_unimport);
137}
138
139
140# the entity of general import()
141
# spent 8.57ms (2.02+6.56) within Mouse::Exporter::do_import which was called 40 times, avg 214µs/call: # 2 times (97µs+489µs) by Any::Moose::_install_module at line 2 of (eval 83)[Any/Moose.pm:152], avg 293µs/call # 2 times (107µs+478µs) by Any::Moose::_install_module at line 2 of (eval 33)[Any/Moose.pm:152], avg 292µs/call # 2 times (91µs+459µs) by Any::Moose::_install_module at line 2 of (eval 96)[Any/Moose.pm:152], avg 275µs/call # 2 times (95µs+432µs) by Any::Moose::_install_module at line 2 of (eval 10)[Any/Moose.pm:152], avg 263µs/call # 2 times (86µs+416µs) by Any::Moose::_install_module at line 2 of (eval 85)[Any/Moose.pm:152], avg 251µs/call # once (56µs+435µs) by Any::Moose::_install_module at line 2 of (eval 93)[Any/Moose.pm:152] # once (48µs+413µs) by Any::Moose::_install_module at line 2 of (eval 9)[Any/Moose.pm:152] # once (75µs+344µs) by MouseX::Getopt::OptionTypeMap::BEGIN@10 at line 10 of MouseX/Getopt/OptionTypeMap.pm # once (45µs+340µs) by MouseX::Getopt::Meta::Attribute::BEGIN@10 at line 10 of MouseX/Getopt/Meta/Attribute.pm # once (45µs+336µs) by MouseX::Getopt::Meta::Attribute::NoGetopt::BEGIN@10 at line 10 of MouseX/Getopt/Meta/Attribute/NoGetopt.pm # once (53µs+318µs) by MouseX::Getopt::Basic::BEGIN@10 at line 10 of MouseX/Getopt/Basic.pm # once (54µs+253µs) by Any::Moose::_install_module at line 2 of (eval 87)[Any/Moose.pm:152] # once (55µs+242µs) by MouseX::Getopt::Dashes::BEGIN@10 at line 10 of MouseX/Getopt/Dashes.pm # once (43µs+243µs) by MouseX::Getopt::Meta::Attribute::Trait::NoGetopt::BEGIN@10 at line 10 of MouseX/Getopt/Meta/Attribute/Trait/NoGetopt.pm # once (42µs+242µs) by MouseX::Getopt::BEGIN@10 at line 10 of MouseX/Getopt.pm # once (43µs+234µs) by MouseX::Getopt::Meta::Attribute::Trait::BEGIN@10 at line 10 of MouseX/Getopt/Meta/Attribute/Trait.pm # once (41µs+226µs) by MouseX::Getopt::GLD::BEGIN@10 at line 10 of MouseX/Getopt/GLD.pm # once (56µs+139µs) by Any::Moose::_install_module at line 2 of (eval 111)[Any/Moose.pm:152] # once (49µs+129µs) by Any::Moose::_install_module at line 2 of (eval 94)[Any/Moose.pm:152] # once (48µs+110µs) by Any::Moose::_install_module at line 2 of (eval 88)[Any/Moose.pm:152] # once (74µs+25µs) by Mouse::Util::BEGIN@20 at line 65 of Mouse.pm # once (74µs+24µs) by Mouse::Meta::Module::BEGIN@2 at line 2 of Mouse/Meta/Module.pm # once (72µs+19µs) by Mouse::Object::BEGIN@2 at line 2 of Mouse/Object.pm # once (60µs+18µs) by Mouse::Meta::Role::Application::BEGIN@2 at line 2 of Mouse/Meta/Role/Application.pm # once (60µs+18µs) by Mouse::Meta::Class::BEGIN@2 at line 2 of Mouse/Meta/Class.pm # once (56µs+22µs) by Mouse::Meta::TypeConstraint::BEGIN@2 at line 2 of Mouse/Meta/TypeConstraint.pm # once (60µs+16µs) by Mouse::Util::BEGIN@20 at line 67 of Mouse.pm # once (58µs+18µs) by Mouse::Meta::Role::BEGIN@2 at line 2 of Mouse/Meta/Role.pm # once (56µs+16µs) by Mouse::Meta::Attribute::BEGIN@2 at line 2 of Mouse/Meta/Attribute.pm # once (54µs+16µs) by Mouse::Util::BEGIN@20 at line 66 of Mouse.pm # once (30µs+29µs) by MouseX::Getopt::Meta::Attribute::BEGIN@11 at line 11 of MouseX/Getopt/Meta/Attribute.pm # once (30µs+28µs) by MouseX::Getopt::Meta::Attribute::Trait::BEGIN@11 at line 11 of MouseX/Getopt/Meta/Attribute/Trait.pm # once (45µs+12µs) by MouseX::Getopt::OptionTypeMap::BEGIN@11 at line 11 of MouseX/Getopt/OptionTypeMap.pm # once (31µs+9µs) by Mouse::Meta::Role::Composite::BEGIN@2 at line 2 of Mouse/Meta/Role/Composite.pm # once (31µs+7µs) by Mouse::Util::TypeConstraints::BEGIN@2 at line 2 of Mouse/Util/TypeConstraints.pm
sub do_import {
1427402.62ms my($package, @args) = @_;
143
144 my $spec = $SPEC{$package}
145 || Carp::confess("The package $package package does not use Mouse::Exporter");
146
14740239µs my $into = _get_caller_package(ref($args[0]) ? shift @args : undef);
# spent 239µs making 40 calls to Mouse::Exporter::_get_caller_package, avg 6µs/call
148
149 my @exports;
150 my @traits;
151
152 while(@args){
153 my $arg = shift @args;
1543051µs if($arg =~ s/^-//){
# spent 51µs making 30 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 my $group = $spec->{groups}{$arg}
164 || Carp::confess(qq{The $package package does not export the group "$arg"});
165 push @exports, @{$group};
166 }
167 else{
168 push @exports, $arg;
169 }
170 }
171
172 # strict->import;
173 $^H |= $strict_bits;
174 # warnings->import('all', FATAL => 'recursion');
175 ${^WARNING_BITS} |= $warnings::Bits{all};
176 ${^WARNING_BITS} |= $warnings_extra_bits;
177
178 if($spec->{INIT_META}){
179 my $meta;
180 foreach my $init_meta(@{$spec->{INIT_META}}){
181255.74ms $meta = $package->$init_meta(for_class => $into);
# spent 3.42ms making 10 calls to Mouse::init_meta, avg 342µs/call # spent 1.87ms making 10 calls to Mouse::Role::init_meta, avg 187µs/call # spent 456µs making 5 calls to MouseX::StrictConstructor::init_meta, avg 91µs/call
182 }
183
184 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 if(@exports){
206 my @export_table;
207 foreach my $keyword(@exports){
208 push @export_table,
209 $keyword => ($spec->{EXPORTS}{$keyword}
210 || Carp::confess(qq{The $package package does not export "$keyword"})
211 );
212 }
21312102µs Mouse::Util::install_subroutines($into, @export_table);
# spent 102µs making 12 calls to Mouse::Util::install_subroutines, avg 9µs/call
214 }
215 else{
21628422µs Mouse::Util::install_subroutines($into, %{$spec->{DEFAULT}});
# spent 422µs making 28 calls to Mouse::Util::install_subroutines, avg 15µs/call
217 }
218 return;
219}
220
221# the entity of general unimport()
222
# spent 899µs (835+63) within Mouse::Exporter::do_unimport which was called 11 times, avg 82µs/call: # once (94µs+5µs) by MouseX::Getopt::Meta::Attribute::Trait::BEGIN@34 at line 34 of MouseX/Getopt/Meta/Attribute/Trait.pm # once (89µs+7µs) by MouseX::Getopt::GLD::BEGIN@73 at line 73 of MouseX/Getopt/GLD.pm # once (89µs+5µs) by MouseX::Getopt::BEGIN@14 at line 14 of MouseX/Getopt.pm # once (82µs+9µs) by MouseX::Getopt::Basic::BEGIN@235 at line 235 of MouseX/Getopt/Basic.pm # once (84µs+5µs) by MouseX::Getopt::Dashes::BEGIN@26 at line 26 of MouseX/Getopt/Dashes.pm # once (81µs+5µs) by MouseX::Getopt::Meta::Attribute::Trait::NoGetopt::BEGIN@11 at line 11 of MouseX/Getopt/Meta/Attribute/Trait/NoGetopt.pm # once (79µs+5µs) by MouseX::Getopt::Meta::Attribute::Trait::BEGIN@35 at line 35 of MouseX/Getopt/Meta/Attribute/Trait.pm # once (74µs+6µs) by MouseX::Getopt::Meta::Attribute::NoGetopt::BEGIN@15 at line 15 of MouseX/Getopt/Meta/Attribute/NoGetopt.pm # once (70µs+5µs) by MouseX::Getopt::Meta::Attribute::BEGIN@16 at line 16 of MouseX/Getopt/Meta/Attribute.pm # once (56µs+6µs) by MouseX::Getopt::OptionTypeMap::BEGIN@75 at line 75 of MouseX/Getopt/OptionTypeMap.pm # once (38µs+5µs) by MouseX::Getopt::OptionTypeMap::BEGIN@76 at line 76 of MouseX/Getopt/OptionTypeMap.pm
sub do_unimport {
223425842µs my($package, $arg) = @_;
224
225 my $spec = $SPEC{$package}
226 || Carp::confess("The package $package does not use Mouse::Exporter");
227
2281163µs my $from = _get_caller_package($arg);
# spent 63µs making 11 calls to Mouse::Exporter::_get_caller_package, avg 6µs/call
229
230 my $stash = do{
2312155µs264µs
# spent 38µs (13+25) within Mouse::Exporter::BEGIN@231 which was called: # once (13µs+25µs) by Mouse::BEGIN@4 at line 231
no strict 'refs';
# spent 38µs making 1 call to Mouse::Exporter::BEGIN@231 # spent 26µ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 302µs within Mouse::Exporter::_get_caller_package which was called 51 times, avg 6µs/call: # 40 times (239µs+0s) by Mouse::Exporter::do_import at line 147, avg 6µs/call # 11 times (63µs+0s) by Mouse::Exporter::do_unimport at line 228, avg 6µs/call
sub _get_caller_package {
246150382µ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 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 return scalar caller(1);
257 }
258}
259
260#sub _spec{ %SPEC }
261
26215µs1;
263__END__
 
# spent 51µs within Mouse::Exporter::CORE:subst which was called 30 times, avg 2µs/call: # 30 times (51µs+0s) by Mouse::Exporter::do_import at line 154, avg 2µs/call
sub Mouse::Exporter::CORE:subst; # opcode