← Index
NYTProf Performance Profile   « block view • line view • sub view »
For mongo_pain.pl
  Run on Fri Mar 25 17:00:29 2011
Reported on Fri Mar 25 17:07:09 2011

Filename/usr/local/lib/perl/5.10.1/Mouse/Exporter.pm
StatementsExecuted 1088 statements in 4.25ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.39ms1.39msMouse::Exporter::::BEGIN@4 Mouse::Exporter::BEGIN@4
191816603µs2.56msMouse::Exporter::::do_import Mouse::Exporter::do_import
311405µs419µsMouse::Exporter::::build_import_methods Mouse::Exporter::build_import_methods
555228µs245µsMouse::Exporter::::do_unimport Mouse::Exporter::do_unimport
33385µs570µsMouse::Exporter::::setup_import_methods Mouse::Exporter::setup_import_methods
242175µs75µsMouse::Exporter::::_get_caller_package Mouse::Exporter::_get_caller_package
11122µs26µsMouse::Exporter::::BEGIN@2 Mouse::Exporter::BEGIN@2
221122µs22µsMouse::Exporter::::CORE:subst Mouse::Exporter::CORE:subst (opcode)
11120µs37µsMouse::Exporter::::BEGIN@10 Mouse::Exporter::BEGIN@10
33319µs19µsMouse::Exporter::::import Mouse::Exporter::import
11114µs28µsMouse::Exporter::::BEGIN@230 Mouse::Exporter::BEGIN@230
11110µs22µsMouse::Exporter::::BEGIN@3 Mouse::Exporter::BEGIN@3
11110µs22µsMouse::Exporter::::BEGIN@96 Mouse::Exporter::BEGIN@96
0000s0sMouse::Exporter::::__ANON__[:43] Mouse::Exporter::__ANON__[:43]
0000s0sMouse::Exporter::::__ANON__[:47] Mouse::Exporter::__ANON__[:47]
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;
2332µs230µ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
use strict;
# spent 26µs making 1 call to Mouse::Exporter::BEGIN@2 # spent 4µs making 1 call to strict::import
3329µs233µ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
use warnings;
# spent 22µs making 1 call to Mouse::Exporter::BEGIN@3 # spent 12µs making 1 call to warnings::import
43578µs11.39ms
# spent 1.39ms within Mouse::Exporter::BEGIN@4 which was called: # once (1.39ms+0s) by Mouse::BEGIN@4 at line 4
use Carp ();
# spent 1.39ms making 1 call to Mouse::Exporter::BEGIN@4
5
61300nsmy %SPEC;
7
81200nsmy $strict_bits;
91100nsmy $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
BEGIN{
1112µs18µs $strict_bits = strict::bits(qw(subs refs vars));
# spent 8µs making 1 call to strict::bits
1217µs19µs $warnings_extra_bits = warnings::bits(FATAL => 'recursion');
# spent 9µs making 1 call to warnings::bits
131493µs137µ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()
17180µsrequire 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
sub import{
20 # strict->import;
2133µs $^H |= $strict_bits;
22 # warnings->import('all', FATAL => 'recursion');
2336µs ${^WARNING_BITS} |= $warnings::Bits{all};
2435µs ${^WARNING_BITS} |= $warnings_extra_bits;
25314µ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
sub setup_import_methods{
3037µs my($class, %args) = @_;
31
3236µs my $exporting_package = $args{exporting_package} ||= caller();
33
34319µs3419µ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 },
48377µs367µs );
# spent 67µs making 3 calls to Mouse::Util::install_subroutines, avg 22µs/call
49314µ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
sub build_import_methods{
5335µs my($self, %args) = @_;
54
5532µs my $exporting_package = $args{exporting_package} ||= caller();
56
5733µs $SPEC{$exporting_package} = \%args;
58
59 # canonicalize args
603800ns my @export_from;
6132µ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{
7333µs @export_from = ($exporting_package);
74 }
75
763600ns my %exports;
773300ns my @removables;
783300ns my @all;
79
803300ns my @init_meta_methods;
81
8233µs foreach my $package(@export_from){
8332µs my $spec = $SPEC{$package} or next;
84
8534µs if(my $as_is = $spec->{as_is}){
8632µs foreach my $thingy (@{$as_is}){
874312µs my($code_package, $code_name, $code);
88
894323µs if(ref($thingy)){
902400ns $code = $thingy;
91216µs24µ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{
94419µs $code_package = $package;
95418µs $code_name = $thingy;
963979µs235µ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
no strict 'refs';
# spent 22µs making 1 call to Mouse::Exporter::BEGIN@96 # spent 13µs making 1 call to strict::unimport
9741140µs $code = \&{ $code_package . '::' . $code_name };
98 }
99
1004326µs push @all, $code_name;
1014323µs $exports{$code_name} = $code;
1024353µs if($code_package eq $package){
103 push @removables, $code_name;
104 }
105 }
106 }
107
108346µs310µ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 }
11433µs $args{EXPORTS} = \%exports;
11536µs $args{REMOVABLES} = \@removables;
116
11735µs $args{groups}{all} ||= \@all;
118
11933µs if(my $default_list = $args{groups}{default}){
1201100ns my %default;
1211900ns foreach my $keyword(@{$default_list}){
122 $default{$keyword} = $exports{$keyword}
123 || Carp::confess(qq{The $exporting_package package does not export "$keyword"});
124 }
1251900ns $args{DEFAULT} = \%default;
126 }
127 else{
12822µs $args{groups}{default} ||= \@all;
12921µs $args{DEFAULT} = $args{EXPORTS};
130 }
131
13232µs if(@init_meta_methods){
133 $args{INIT_META} = \@init_meta_methods;
134 }
135
136316µ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
sub do_import {
1411927µs my($package, @args) = @_;
142
1431914µs my $spec = $SPEC{$package}
144 || Carp::confess("The package $package package does not use Mouse::Exporter");
145
1461942µs1958µ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
148193µs my @exports;
149192µs my @traits;
150
1511916µs while(@args){
152116µs my $arg = shift @args;
1531176µs2222µ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/^://){
16288µs my $group = $spec->{groups}{$arg}
163 || Carp::confess(qq{The $package package does not export the group "$arg"});
164816µs push @exports, @{$group};
165 }
166 else{
16732µs push @exports, $arg;
168 }
169 }
170
171 # strict->import;
1721922µs $^H |= $strict_bits;
173 # warnings->import('all', FATAL => 'recursion');
1741943µs ${^WARNING_BITS} |= $warnings::Bits{all};
1751929µs ${^WARNING_BITS} |= $warnings_extra_bits;
176
1771914µs if($spec->{INIT_META}){
17882µs my $meta;
179811µs foreach my $init_meta(@{$spec->{INIT_META}}){
180827µs81.62ms $meta = $package->$init_meta(for_class => $into);
# spent 1.62ms making 8 calls to Mouse::init_meta, avg 203µs/call
181 }
182
18384µ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
2041917µs if(@exports){
20592µs my @export_table;
20699µs foreach my $keyword(@exports){
2073544µs push @export_table,
208 $keyword => ($spec->{EXPORTS}{$keyword}
209 || Carp::confess(qq{The $package package does not export "$keyword"})
210 );
211 }
2129123µs987µ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{
21510234µs10172µs Mouse::Util::install_subroutines($into, %{$spec->{DEFAULT}});
# spent 172µs making 10 calls to Mouse::Util::install_subroutines, avg 17µs/call
216 }
2171986µ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]
sub do_unimport {
22256µs my($package, $arg) = @_;
223
22455µs my $spec = $SPEC{$package}
225 || Carp::confess("The package $package does not use Mouse::Exporter");
226
227511µs517µs my $from = _get_caller_package($arg);
# spent 17µs making 5 calls to Mouse::Exporter::_get_caller_package, avg 3µs/call
228
22953µs my $stash = do{
2303227µs241µ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
no strict 'refs';
# spent 28µs making 1 call to Mouse::Exporter::BEGIN@230 # spent 13µs making 1 call to strict::unimport
231511µs \%{$from . '::'}
232 };
233
234510µs for my $keyword (@{ $spec->{REMOVABLES} }) {
2355019µs next if !exists $stash->{$keyword};
2365024µs my $gv = \$stash->{$keyword};
237
238 # remove what is from us
23950111µs if(ref($gv) eq 'GLOB' && *{$gv}{CODE} == $spec->{EXPORTS}{$keyword}){
240 delete $stash->{$keyword};
241 }
242 }
243529µs return;
244}
245
246
# spent 75µs within Mouse::Exporter::_get_caller_package which was called 24 times, avg 3µs/call: # 19 times (58µs+0s) by Mouse::Exporter::do_import at line 146, avg 3µs/call # 5 times (17µs+0s) by Mouse::Exporter::do_unimport at line 227, avg 3µs/call
sub _get_caller_package {
2472410µs my($arg) = @_;
248
249 # We need one extra level because it's called by import so there's a layer
250 # of indirection
2512420µ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{
25721102µs return scalar caller(1);
258 }
259}
260
26113µs1;
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
sub Mouse::Exporter::CORE:subst; # opcode