Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Exporter.pm |
Statements | Executed 8279 statements in 14.3ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 3.50ms | 75.0ms | BEGIN@13 | Moose::Exporter::
1 | 1 | 1 | 1.95ms | 2.41ms | BEGIN@17 | Moose::Exporter::
26 | 1 | 1 | 1.58ms | 16.7ms | __ANON__[:137] | Moose::Exporter::
17 | 1 | 1 | 1.15ms | 1.18ms | _remove_keywords | Moose::Exporter::
176 | 1 | 1 | 1.04ms | 1.97ms | __ANON__[:379] | Moose::Exporter::
26 | 26 | 25 | 845µs | 69.0ms | __ANON__[:519] | Moose::Exporter::
1 | 1 | 1 | 729µs | 894µs | BEGIN@15 | Moose::Exporter::
176 | 1 | 1 | 644µs | 644µs | _late_curry_wrapper | Moose::Exporter::
26 | 1 | 1 | 337µs | 337µs | _collect_metaroles | Moose::Exporter::
3 | 1 | 1 | 286µs | 454µs | _make_sub_exporter_params | Moose::Exporter::
26 | 1 | 1 | 198µs | 720µs | _apply_metaroles | Moose::Exporter::
26 | 1 | 1 | 181µs | 265µs | _strip_traits | Moose::Exporter::
60 | 1 | 1 | 151µs | 363µs | __ANON__[:252] | Moose::Exporter::
184 | 1 | 1 | 149µs | 149µs | __ANON__[:307] | Moose::Exporter::
3 | 1 | 1 | 143µs | 2.20ms | build_import_methods | Moose::Exporter::
26 | 1 | 1 | 127µs | 167µs | _strip_metaclass | Moose::Exporter::
52 | 2 | 1 | 126µs | 297µs | __ANON__[:42] | Moose::Exporter::
26 | 1 | 1 | 120µs | 157µs | _strip_meta_name | Moose::Exporter::
17 | 17 | 16 | 115µs | 1.29ms | __ANON__[:706] | Moose::Exporter::
41 | 2 | 1 | 99µs | 99µs | _sub_from_package | Moose::Exporter::
16 | 1 | 1 | 54µs | 54µs | _make_wrapped_sub_with_meta | Moose::Exporter::
26 | 1 | 1 | 48µs | 48µs | _get_caller | Moose::Exporter::
43 | 1 | 1 | 41µs | 41µs | _flag_as_reexport (xsub) | Moose::Exporter::
3 | 1 | 1 | 40µs | 40µs | _make_init_meta | Moose::Exporter::
3 | 1 | 1 | 30µs | 101µs | _follow_also | Moose::Exporter::
3 | 1 | 1 | 28µs | 1.18ms | _make_exporter | Moose::Exporter::
3 | 3 | 3 | 27µs | 2.22ms | setup_import_methods | Moose::Exporter::
3 | 1 | 1 | 26µs | 43µs | _die_if_cycle_found_in_also_list_for_package | Moose::Exporter::
32 | 1 | 1 | 23µs | 23µs | _export_is_flagged (xsub) | Moose::Exporter::
3 | 3 | 3 | 22µs | 63µs | import | Moose::Exporter::
3 | 1 | 1 | 21µs | 21µs | _make_import_sub | Moose::Exporter::
3 | 1 | 1 | 15µs | 15µs | _make_unimport_sub | Moose::Exporter::
6 | 2 | 1 | 13µs | 13µs | _also_list_for_package | Moose::Exporter::
3 | 1 | 1 | 13µs | 16µs | _follow_also_real | Moose::Exporter::
3 | 1 | 1 | 11µs | 11µs | _parse_trait_aliases | Moose::Exporter::
1 | 1 | 1 | 9µs | 19µs | BEGIN@716 | Moose::Exporter::
1 | 1 | 1 | 8µs | 8µs | BEGIN@2 | Moose::Exporter::
1 | 1 | 1 | 7µs | 36µs | BEGIN@14 | Moose::Exporter::
1 | 1 | 1 | 7µs | 18µs | BEGIN@133 | Moose::Exporter::
1 | 1 | 1 | 6µs | 16µs | BEGIN@321 | Moose::Exporter::
1 | 1 | 1 | 6µs | 17µs | BEGIN@9 | Moose::Exporter::
3 | 1 | 1 | 6µs | 6µs | _die_if_also_list_cycles_back_to_existing_stack | Moose::Exporter::
1 | 1 | 1 | 6µs | 26µs | BEGIN@18 | Moose::Exporter::
1 | 1 | 1 | 6µs | 16µs | BEGIN@132 | Moose::Exporter::
1 | 1 | 1 | 6µs | 26µs | BEGIN@16 | Moose::Exporter::
1 | 1 | 1 | 6µs | 26µs | BEGIN@12 | Moose::Exporter::
1 | 1 | 1 | 6µs | 9µs | BEGIN@10 | Moose::Exporter::
1 | 1 | 1 | 6µs | 14µs | BEGIN@726 | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:228] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:356] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:388] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:410] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:523] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:537] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:549] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | __ANON__[:778] | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | _apply_meta_traits | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | _curry_wrapper | Moose::Exporter::
0 | 0 | 0 | 0s | 0s | _make_wrapped_sub | Moose::Exporter::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moose::Exporter; | ||||
2 | # spent 8µs within Moose::Exporter::BEGIN@2 which was called:
# once (8µs+0s) by Moose::BEGIN@18 at line 4 | ||||
3 | 1 | 4µs | $Moose::Exporter::AUTHORITY = 'cpan:STEVAN'; | ||
4 | 1 | 28µs | 1 | 8µs | } # spent 8µs making 1 call to Moose::Exporter::BEGIN@2 |
5 | { | ||||
6 | 2 | 800ns | $Moose::Exporter::VERSION = '2.1005'; | ||
7 | } | ||||
8 | |||||
9 | 2 | 22µs | 2 | 27µs | # spent 17µs (6+10) within Moose::Exporter::BEGIN@9 which was called:
# once (6µs+10µs) by Moose::BEGIN@18 at line 9 # spent 17µs making 1 call to Moose::Exporter::BEGIN@9
# spent 10µs making 1 call to strict::import |
10 | 2 | 35µs | 2 | 12µs | # spent 9µs (6+3) within Moose::Exporter::BEGIN@10 which was called:
# once (6µs+3µs) by Moose::BEGIN@18 at line 10 # spent 9µs making 1 call to Moose::Exporter::BEGIN@10
# spent 3µs making 1 call to warnings::import |
11 | |||||
12 | 2 | 20µs | 2 | 46µs | # spent 26µs (6+20) within Moose::Exporter::BEGIN@12 which was called:
# once (6µs+20µs) by Moose::BEGIN@18 at line 12 # spent 26µs making 1 call to Moose::Exporter::BEGIN@12
# spent 20µs making 1 call to Exporter::import |
13 | 2 | 106µs | 1 | 75.0ms | # spent 75.0ms (3.50+71.5) within Moose::Exporter::BEGIN@13 which was called:
# once (3.50ms+71.5ms) by Moose::BEGIN@18 at line 13 # spent 75.0ms making 1 call to Moose::Exporter::BEGIN@13 |
14 | 2 | 32µs | 2 | 65µs | # spent 36µs (7+29) within Moose::Exporter::BEGIN@14 which was called:
# once (7µs+29µs) by Moose::BEGIN@18 at line 14 # spent 36µs making 1 call to Moose::Exporter::BEGIN@14
# spent 29µs making 1 call to Exporter::import |
15 | 2 | 100µs | 1 | 894µs | # spent 894µs (729+165) within Moose::Exporter::BEGIN@15 which was called:
# once (729µs+165µs) by Moose::BEGIN@18 at line 15 # spent 894µs making 1 call to Moose::Exporter::BEGIN@15 |
16 | 2 | 24µs | 2 | 46µs | # spent 26µs (6+20) within Moose::Exporter::BEGIN@16 which was called:
# once (6µs+20µs) by Moose::BEGIN@18 at line 16 # spent 26µs making 1 call to Moose::Exporter::BEGIN@16
# spent 20µs making 1 call to Exporter::import |
17 | 3 | 93µs | 3 | 2.53ms | # spent 2.41ms (1.95+459µs) within Moose::Exporter::BEGIN@17 which was called:
# once (1.95ms+459µs) by Moose::BEGIN@18 at line 17 # spent 2.41ms making 1 call to Moose::Exporter::BEGIN@17
# spent 107µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
# spent 7µs making 1 call to UNIVERSAL::VERSION |
18 | 2 | 374µs | 2 | 46µs | # spent 26µs (6+20) within Moose::Exporter::BEGIN@18 which was called:
# once (6µs+20µs) by Moose::BEGIN@18 at line 18 # spent 26µs making 1 call to Moose::Exporter::BEGIN@18
# spent 20µs making 1 call to Exporter::import |
19 | |||||
20 | 1 | 100ns | my %EXPORT_SPEC; | ||
21 | |||||
22 | # spent 2.22ms (27µs+2.20) within Moose::Exporter::setup_import_methods which was called 3 times, avg 741µs/call:
# once (10µs+860µs) by Moose::Meta::Attribute::BEGIN@24 at line 44 of Moose/Util/TypeConstraints.pm
# once (8µs+691µs) by MooseX::Storage::Meta::Attribute::Trait::DoNotSerialize::BEGIN@9 at line 94 of Moose/Role.pm
# once (9µs+646µs) by Atom::BEGIN@2 at line 137 of Moose.pm | ||||
23 | 3 | 4µs | my ( $class, %args ) = @_; | ||
24 | |||||
25 | 3 | 4µs | $args{exporting_package} ||= caller(); | ||
26 | |||||
27 | 3 | 19µs | 3 | 2.20ms | $class->build_import_methods( # spent 2.20ms making 3 calls to Moose::Exporter::build_import_methods, avg 732µs/call |
28 | %args, | ||||
29 | install => [qw(import unimport init_meta)] | ||||
30 | ); | ||||
31 | } | ||||
32 | |||||
33 | # A reminder to intrepid Moose hackers | ||||
34 | # there may be more than one level of exporter | ||||
35 | # don't make doy cry. -- perigrin | ||||
36 | |||||
37 | # spent 2.20ms (143µs+2.05) within Moose::Exporter::build_import_methods which was called 3 times, avg 732µs/call:
# 3 times (143µs+2.05ms) by Moose::Exporter::setup_import_methods at line 27, avg 732µs/call | ||||
38 | 3 | 4µs | my ( $class, %args ) = @_; | ||
39 | |||||
40 | 3 | 2µs | my $exporting_package = $args{exporting_package} ||= caller(); | ||
41 | |||||
42 | 55 | 114µs | 52 | 171µs | # spent 297µs (126+171) within Moose::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Exporter.pm:42] which was called 52 times, avg 6µs/call:
# 26 times (68µs+88µs) by Moose::Exporter::_apply_metaroles at line 566, avg 6µs/call
# 26 times (58µs+83µs) by Moose::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Exporter.pm:137] at line 108, avg 5µs/call # spent 171µs making 52 calls to Class::MOP::class_of, avg 3µs/call |
43 | |||||
44 | 3 | 2µs | $EXPORT_SPEC{$exporting_package} = \%args; | ||
45 | |||||
46 | 3 | 6µs | 3 | 101µs | my @exports_from = $class->_follow_also($exporting_package); # spent 101µs making 3 calls to Moose::Exporter::_follow_also, avg 34µs/call |
47 | |||||
48 | 3 | 2µs | my $export_recorder = {}; | ||
49 | 3 | 700ns | my $is_reexport = {}; | ||
50 | |||||
51 | 3 | 11µs | 3 | 454µs | my $exports = $class->_make_sub_exporter_params( # spent 454µs making 3 calls to Moose::Exporter::_make_sub_exporter_params, avg 151µs/call |
52 | [ $exporting_package, @exports_from ], | ||||
53 | $export_recorder, | ||||
54 | $is_reexport, | ||||
55 | $args{meta_lookup}, # so that we don't pass through the default | ||||
56 | ); | ||||
57 | |||||
58 | 3 | 6µs | 3 | 1.18ms | my $exporter = $class->_make_exporter( # spent 1.18ms making 3 calls to Moose::Exporter::_make_exporter, avg 394µs/call |
59 | $exports, | ||||
60 | $is_reexport, | ||||
61 | $meta_lookup, | ||||
62 | ); | ||||
63 | |||||
64 | 3 | 300ns | my %methods; | ||
65 | 3 | 7µs | 3 | 21µs | $methods{import} = $class->_make_import_sub( # spent 21µs making 3 calls to Moose::Exporter::_make_import_sub, avg 7µs/call |
66 | $exporting_package, | ||||
67 | $exporter, | ||||
68 | \@exports_from, | ||||
69 | $is_reexport, | ||||
70 | $meta_lookup, | ||||
71 | ); | ||||
72 | |||||
73 | 3 | 7µs | 3 | 15µs | $methods{unimport} = $class->_make_unimport_sub( # spent 15µs making 3 calls to Moose::Exporter::_make_unimport_sub, avg 5µs/call |
74 | $exporting_package, | ||||
75 | $exports, | ||||
76 | $export_recorder, | ||||
77 | $is_reexport, | ||||
78 | $meta_lookup, | ||||
79 | ); | ||||
80 | |||||
81 | 3 | 7µs | 3 | 40µs | $methods{init_meta} = $class->_make_init_meta( # spent 40µs making 3 calls to Moose::Exporter::_make_init_meta, avg 13µs/call |
82 | $exporting_package, | ||||
83 | \%args, | ||||
84 | $meta_lookup, | ||||
85 | ); | ||||
86 | |||||
87 | 3 | 6µs | 3 | 68µs | my $package = Class::MOP::Package->initialize($exporting_package); # spent 68µs making 3 calls to Class::MOP::Package::initialize, avg 22µs/call |
88 | 3 | 4µs | for my $to_install ( @{ $args{install} || [] } ) { | ||
89 | 9 | 3µs | my $symbol = '&' . $to_install; | ||
90 | next | ||||
91 | 9 | 10µs | 6 | 93µs | unless $methods{$to_install} # spent 93µs making 6 calls to Class::MOP::Package::has_package_symbol, avg 16µs/call |
92 | && !$package->has_package_symbol($symbol); | ||||
93 | 6 | 10µs | 6 | 82µs | $package->add_package_symbol( $symbol, $methods{$to_install} ); # spent 82µs making 6 calls to Class::MOP::Package::add_package_symbol, avg 14µs/call |
94 | } | ||||
95 | |||||
96 | 3 | 11µs | return ( $methods{import}, $methods{unimport}, $methods{init_meta} ); | ||
97 | } | ||||
98 | |||||
99 | # spent 1.18ms (28µs+1.15) within Moose::Exporter::_make_exporter which was called 3 times, avg 394µs/call:
# 3 times (28µs+1.15ms) by Moose::Exporter::build_import_methods at line 58, avg 394µs/call | ||||
100 | 3 | 2µs | my ($class, $exports, $is_reexport, $meta_lookup) = @_; | ||
101 | |||||
102 | return Sub::Exporter::build_exporter( | ||||
103 | { | ||||
104 | exports => $exports, | ||||
105 | groups => { default => [':all'] }, | ||||
106 | # spent 16.7ms (1.58+15.2) within Moose::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Exporter.pm:137] which was called 26 times, avg 644µs/call:
# 26 times (1.58ms+15.2ms) by Sub::Exporter::_do_import at line 380 of Sub/Exporter.pm, avg 644µs/call | ||||
107 | 26 | 6µs | my ($arg, $to_export) = @_; | ||
108 | 26 | 22µs | 26 | 141µs | my $meta = $meta_lookup->($arg->{into}); # spent 141µs making 26 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:42], avg 5µs/call |
109 | |||||
110 | 26 | 10µs | 2 | 1.04ms | goto &Sub::Exporter::default_installer unless $meta; # spent 1.04ms making 2 calls to Sub::Exporter::default_installer, avg 519µs/call |
111 | |||||
112 | # don't overwrite existing symbols with our magically flagged | ||||
113 | # version of it if we would install the same sub that's already | ||||
114 | # in the importer | ||||
115 | |||||
116 | 24 | 1µs | my @filtered_to_export; | ||
117 | 24 | 800ns | my %installed; | ||
118 | 24 | 82µs | for (my $i = 0; $i < @{ $to_export }; $i += 2) { | ||
119 | 322 | 106µs | my ($as, $cv) = @{ $to_export }[$i, $i + 1]; | ||
120 | |||||
121 | 322 | 365µs | 324 | 2.15ms | next if !ref($as) # spent 2.13ms making 322 calls to Class::MOP::Package::has_package_symbol, avg 7µs/call
# spent 13µs making 2 calls to Class::MOP::Package::get_package_symbol, avg 7µs/call |
122 | && $meta->has_package_symbol('&' . $as) | ||||
123 | && $meta->get_package_symbol('&' . $as) == $cv; | ||||
124 | |||||
125 | 320 | 104µs | push @filtered_to_export, $as, $cv; | ||
126 | 320 | 147µs | $installed{$as} = 1 unless ref $as; | ||
127 | } | ||||
128 | |||||
129 | 24 | 23µs | 24 | 12.8ms | Sub::Exporter::default_installer($arg, \@filtered_to_export); # spent 12.8ms making 24 calls to Sub::Exporter::default_installer, avg 534µs/call |
130 | |||||
131 | 24 | 89µs | for my $name ( keys %{$is_reexport} ) { | ||
132 | 2 | 23µs | 2 | 25µs | # spent 16µs (6+9) within Moose::Exporter::BEGIN@132 which was called:
# once (6µs+9µs) by Moose::BEGIN@18 at line 132 # spent 16µs making 1 call to Moose::Exporter::BEGIN@132
# spent 9µs making 1 call to strict::unimport |
133 | 2 | 767µs | 2 | 30µs | # spent 18µs (7+12) within Moose::Exporter::BEGIN@133 which was called:
# once (7µs+12µs) by Moose::BEGIN@18 at line 133 # spent 18µs making 1 call to Moose::Exporter::BEGIN@133
# spent 12µs making 1 call to warnings::unimport |
134 | 46 | 8µs | next unless exists $installed{$name}; | ||
135 | 43 | 172µs | 43 | 41µs | _flag_as_reexport( \*{ join q{::}, $arg->{into}, $name } ); # spent 41µs making 43 calls to Moose::Exporter::_flag_as_reexport, avg 944ns/call |
136 | } | ||||
137 | }, | ||||
138 | } | ||||
139 | 3 | 25µs | 3 | 1.15ms | ); # spent 1.15ms making 3 calls to Sub::Exporter::build_exporter, avg 384µs/call |
140 | } | ||||
141 | |||||
142 | # spent 101µs (30+72) within Moose::Exporter::_follow_also which was called 3 times, avg 34µs/call:
# 3 times (30µs+72µs) by Moose::Exporter::build_import_methods at line 46, avg 34µs/call | ||||
143 | 3 | 1µs | my $class = shift; | ||
144 | 3 | 600ns | my $exporting_package = shift; | ||
145 | |||||
146 | 3 | 6µs | 3 | 43µs | _die_if_cycle_found_in_also_list_for_package($exporting_package); # spent 43µs making 3 calls to Moose::Exporter::_die_if_cycle_found_in_also_list_for_package, avg 14µs/call |
147 | |||||
148 | 3 | 31µs | 6 | 29µs | return uniq( _follow_also_real($exporting_package) ); # spent 16µs making 3 calls to Moose::Exporter::_follow_also_real, avg 5µs/call
# spent 13µs making 3 calls to List::MoreUtils::uniq, avg 4µs/call |
149 | } | ||||
150 | |||||
151 | # spent 16µs (13+3) within Moose::Exporter::_follow_also_real which was called 3 times, avg 5µs/call:
# 3 times (13µs+3µs) by Moose::Exporter::_follow_also at line 148, avg 5µs/call | ||||
152 | 3 | 700ns | my $exporting_package = shift; | ||
153 | 3 | 2µs | 3 | 3µs | my @also = _also_list_for_package($exporting_package); # spent 3µs making 3 calls to Moose::Exporter::_also_list_for_package, avg 1µs/call |
154 | |||||
155 | 3 | 7µs | return map { $_, _follow_also_real($_) } @also; | ||
156 | } | ||||
157 | |||||
158 | sub _also_list_for_package { | ||||
159 | 6 | 1µs | my $package = shift; | ||
160 | |||||
161 | 6 | 2µs | if ( !exists $EXPORT_SPEC{$package} ) { | ||
162 | my $loaded = is_class_loaded($package); | ||||
163 | |||||
164 | die "Package in also ($package) does not seem to " | ||||
165 | . "use Moose::Exporter" | ||||
166 | . ( $loaded ? "" : " (is it loaded?)" ); | ||||
167 | } | ||||
168 | |||||
169 | 6 | 3µs | my $also = $EXPORT_SPEC{$package}{also}; | ||
170 | |||||
171 | 6 | 18µs | return unless defined $also; | ||
172 | |||||
173 | return ref $also ? @$also : $also; | ||||
174 | } | ||||
175 | |||||
176 | # this is no Tarjan algorithm, but for the list sizes expected, | ||||
177 | # brute force will probably be fine (and more maintainable) | ||||
178 | # spent 43µs (26+17) within Moose::Exporter::_die_if_cycle_found_in_also_list_for_package which was called 3 times, avg 14µs/call:
# 3 times (26µs+17µs) by Moose::Exporter::_follow_also at line 146, avg 14µs/call | ||||
179 | 3 | 700ns | my $package = shift; | ||
180 | 3 | 16µs | 6 | 17µs | _die_if_also_list_cycles_back_to_existing_stack( # spent 10µs making 3 calls to Moose::Exporter::_also_list_for_package, avg 3µs/call
# spent 6µs making 3 calls to Moose::Exporter::_die_if_also_list_cycles_back_to_existing_stack, avg 2µs/call |
181 | [ _also_list_for_package($package) ], | ||||
182 | [$package], | ||||
183 | ); | ||||
184 | } | ||||
185 | |||||
186 | # spent 6µs within Moose::Exporter::_die_if_also_list_cycles_back_to_existing_stack which was called 3 times, avg 2µs/call:
# 3 times (6µs+0s) by Moose::Exporter::_die_if_cycle_found_in_also_list_for_package at line 180, avg 2µs/call | ||||
187 | 3 | 2µs | my ( $also_list, $existing_stack ) = @_; | ||
188 | |||||
189 | 3 | 8µs | return unless @$also_list && @$existing_stack; | ||
190 | |||||
191 | for my $also_member (@$also_list) { | ||||
192 | for my $stack_member (@$existing_stack) { | ||||
193 | next unless $also_member eq $stack_member; | ||||
194 | |||||
195 | die | ||||
196 | "Circular reference in 'also' parameter to Moose::Exporter between " | ||||
197 | . join( | ||||
198 | ', ', | ||||
199 | @$existing_stack | ||||
200 | ) . " and $also_member"; | ||||
201 | } | ||||
202 | |||||
203 | _die_if_also_list_cycles_back_to_existing_stack( | ||||
204 | [ _also_list_for_package($also_member) ], | ||||
205 | [ $also_member, @$existing_stack ], | ||||
206 | ); | ||||
207 | } | ||||
208 | } | ||||
209 | |||||
210 | # spent 11µs within Moose::Exporter::_parse_trait_aliases which was called 3 times, avg 4µs/call:
# 3 times (11µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 281, avg 4µs/call | ||||
211 | 3 | 700ns | my $class = shift; | ||
212 | 3 | 2µs | my ($package, $aliases) = @_; | ||
213 | |||||
214 | 3 | 400ns | my @ret; | ||
215 | 3 | 2µs | for my $alias (@$aliases) { | ||
216 | my $name; | ||||
217 | if (ref($alias)) { | ||||
218 | reftype($alias) eq 'ARRAY' | ||||
219 | or Moose->throw_error(reftype($alias) . " references are not " | ||||
220 | . "valid arguments to the 'trait_aliases' " | ||||
221 | . "option"); | ||||
222 | |||||
223 | ($alias, $name) = @$alias; | ||||
224 | } | ||||
225 | else { | ||||
226 | ($name = $alias) =~ s/.*:://; | ||||
227 | } | ||||
228 | push @ret, subname "${package}::${name}" => sub () { $alias }; | ||||
229 | } | ||||
230 | |||||
231 | 3 | 8µs | return @ret; | ||
232 | } | ||||
233 | |||||
234 | # spent 454µs (286+168) within Moose::Exporter::_make_sub_exporter_params which was called 3 times, avg 151µs/call:
# 3 times (286µs+168µs) by Moose::Exporter::build_import_methods at line 51, avg 151µs/call | ||||
235 | 3 | 1µs | my $class = shift; | ||
236 | 3 | 600ns | my $packages = shift; | ||
237 | 3 | 600ns | my $export_recorder = shift; | ||
238 | 3 | 600ns | my $is_reexport = shift; | ||
239 | 3 | 2µs | my $meta_lookup_override = shift; | ||
240 | |||||
241 | 3 | 300ns | my %exports; | ||
242 | 3 | 400ns | my $current_meta_lookup; | ||
243 | |||||
244 | 3 | 3µs | for my $package ( @{$packages} ) { | ||
245 | 3 | 2µs | my $args = $EXPORT_SPEC{$package} | ||
246 | or die "The $package package does not use Moose::Exporter\n"; | ||||
247 | |||||
248 | 3 | 2µs | $current_meta_lookup = $meta_lookup_override || $args->{meta_lookup}; | ||
249 | 3 | 300ns | $meta_lookup_override = $current_meta_lookup; | ||
250 | |||||
251 | my $meta_lookup = $current_meta_lookup | ||||
252 | 63 | 3.45ms | 60 | 212µs | # spent 363µs (151+212) within Moose::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Exporter.pm:252] which was called 60 times, avg 6µs/call:
# 60 times (151µs+212µs) by Moose::Role::after or Moose::Role::around or Moose::Role::before or Moose::Role::has or Moose::Role::override or Moose::Role::requires or Moose::Role::with or Moose::extends or Moose::has or Moose::with at line 408, avg 6µs/call # spent 212µs making 60 calls to Class::MOP::class_of, avg 4µs/call |
253 | |||||
254 | 3 | 3µs | for my $name ( @{ $args->{with_meta} } ) { | ||
255 | 16 | 14µs | 16 | 38µs | my $sub = $class->_sub_from_package( $package, $name ) # spent 38µs making 16 calls to Moose::Exporter::_sub_from_package, avg 2µs/call |
256 | or next; | ||||
257 | |||||
258 | 16 | 5µs | my $fq_name = $package . '::' . $name; | ||
259 | |||||
260 | 16 | 27µs | 16 | 54µs | $exports{$name} = $class->_make_wrapped_sub_with_meta( # spent 54µs making 16 calls to Moose::Exporter::_make_wrapped_sub_with_meta, avg 3µs/call |
261 | $fq_name, | ||||
262 | $sub, | ||||
263 | $export_recorder, | ||||
264 | $meta_lookup, | ||||
265 | ) unless exists $exports{$name}; | ||||
266 | } | ||||
267 | |||||
268 | 3 | 3µs | for my $name ( @{ $args->{with_caller} } ) { | ||
269 | my $sub = $class->_sub_from_package( $package, $name ) | ||||
270 | or next; | ||||
271 | |||||
272 | my $fq_name = $package . '::' . $name; | ||||
273 | |||||
274 | $exports{$name} = $class->_make_wrapped_sub( | ||||
275 | $fq_name, | ||||
276 | $sub, | ||||
277 | $export_recorder, | ||||
278 | ) unless exists $exports{$name}; | ||||
279 | } | ||||
280 | |||||
281 | 3 | 9µs | 3 | 11µs | my @extra_exports = $class->_parse_trait_aliases( # spent 11µs making 3 calls to Moose::Exporter::_parse_trait_aliases, avg 4µs/call |
282 | $package, $args->{trait_aliases}, | ||||
283 | ); | ||||
284 | 3 | 7µs | for my $name ( @{ $args->{as_is} }, @extra_exports ) { | ||
285 | 29 | 400ns | my ( $sub, $coderef_name ); | ||
286 | |||||
287 | 29 | 4µs | if ( ref $name ) { | ||
288 | 4 | 400ns | $sub = $name; | ||
289 | |||||
290 | 4 | 200ns | my $coderef_pkg; | ||
291 | 4 | 14µs | 4 | 4µs | ( $coderef_pkg, $coderef_name ) # spent 4µs making 4 calls to Class::MOP::get_code_info, avg 1µs/call |
292 | = Class::MOP::get_code_info($name); | ||||
293 | |||||
294 | 4 | 3µs | if ( $coderef_pkg ne $package ) { | ||
295 | $is_reexport->{$coderef_name} = 1; | ||||
296 | } | ||||
297 | } | ||||
298 | else { | ||||
299 | 25 | 21µs | 25 | 61µs | $sub = $class->_sub_from_package( $package, $name ) # spent 61µs making 25 calls to Moose::Exporter::_sub_from_package, avg 2µs/call |
300 | or next; | ||||
301 | |||||
302 | 25 | 5µs | $coderef_name = $name; | ||
303 | } | ||||
304 | |||||
305 | 29 | 19µs | $export_recorder->{$sub} = 1; | ||
306 | |||||
307 | 184 | 267µs | # spent 149µs within Moose::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Exporter.pm:307] which was called 184 times, avg 808ns/call:
# 184 times (149µs+0s) by Sub::Exporter::default_generator at line 419 of Sub/Exporter.pm, avg 808ns/call | ||
308 | 29 | 50µs | unless exists $exports{$coderef_name}; | ||
309 | } | ||||
310 | } | ||||
311 | |||||
312 | 3 | 8µs | return \%exports; | ||
313 | } | ||||
314 | |||||
315 | sub _sub_from_package { | ||||
316 | 41 | 5µs | my $sclass = shift; | ||
317 | 41 | 1µs | my $package = shift; | ||
318 | 41 | 2µs | my $name = shift; | ||
319 | |||||
320 | 41 | 5µs | my $sub = do { | ||
321 | 2 | 1.43ms | 2 | 26µs | # spent 16µs (6+10) within Moose::Exporter::BEGIN@321 which was called:
# once (6µs+10µs) by Moose::BEGIN@18 at line 321 # spent 16µs making 1 call to Moose::Exporter::BEGIN@321
# spent 10µs making 1 call to strict::unimport |
322 | 41 | 31µs | \&{ $package . '::' . $name }; | ||
323 | }; | ||||
324 | |||||
325 | 41 | 62µs | return $sub if defined &$sub; | ||
326 | |||||
327 | Carp::cluck "Trying to export undefined sub ${package}::${name}"; | ||||
328 | |||||
329 | return; | ||||
330 | } | ||||
331 | |||||
332 | 1 | 0s | our $CALLER; | ||
333 | |||||
334 | sub _make_wrapped_sub { | ||||
335 | my $self = shift; | ||||
336 | my $fq_name = shift; | ||||
337 | my $sub = shift; | ||||
338 | my $export_recorder = shift; | ||||
339 | |||||
340 | # We need to set the package at import time, so that when | ||||
341 | # package Foo imports has(), we capture "Foo" as the | ||||
342 | # package. This lets other packages call Foo::has() and get | ||||
343 | # the right package. This is done for backwards compatibility | ||||
344 | # with existing production code, not because this is a good | ||||
345 | # idea ;) | ||||
346 | return sub { | ||||
347 | my $caller = $CALLER; | ||||
348 | |||||
349 | my $wrapper = $self->_curry_wrapper( $sub, $fq_name, $caller ); | ||||
350 | |||||
351 | my $sub = subname( $fq_name => $wrapper ); | ||||
352 | |||||
353 | $export_recorder->{$sub} = 1; | ||||
354 | |||||
355 | return $sub; | ||||
356 | }; | ||||
357 | } | ||||
358 | |||||
359 | # spent 54µs within Moose::Exporter::_make_wrapped_sub_with_meta which was called 16 times, avg 3µs/call:
# 16 times (54µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 260, avg 3µs/call | ||||
360 | 16 | 3µs | my $self = shift; | ||
361 | 16 | 2µs | my $fq_name = shift; | ||
362 | 16 | 2µs | my $sub = shift; | ||
363 | 16 | 500ns | my $export_recorder = shift; | ||
364 | 16 | 200ns | my $meta_lookup = shift; | ||
365 | |||||
366 | # spent 1.97ms (1.04+932µs) within Moose::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Exporter.pm:379] which was called 176 times, avg 11µs/call:
# 176 times (1.04ms+932µs) by Sub::Exporter::default_generator at line 419 of Sub/Exporter.pm, avg 11µs/call | ||||
367 | 176 | 19µs | my $caller = $CALLER; | ||
368 | |||||
369 | 176 | 137µs | 176 | 644µs | my $wrapper = $self->_late_curry_wrapper( # spent 644µs making 176 calls to Moose::Exporter::_late_curry_wrapper, avg 4µs/call |
370 | $sub, $fq_name, | ||||
371 | $meta_lookup => $caller | ||||
372 | ); | ||||
373 | |||||
374 | 176 | 555µs | 176 | 289µs | my $sub = subname( $fq_name => $wrapper ); # spent 289µs making 176 calls to Sub::Name::subname, avg 2µs/call |
375 | |||||
376 | 176 | 138µs | $export_recorder->{$sub} = 1; | ||
377 | |||||
378 | 176 | 298µs | return $sub; | ||
379 | 16 | 51µs | }; | ||
380 | } | ||||
381 | |||||
382 | sub _curry_wrapper { | ||||
383 | my $class = shift; | ||||
384 | my $sub = shift; | ||||
385 | my $fq_name = shift; | ||||
386 | my @extra = @_; | ||||
387 | |||||
388 | my $wrapper = sub { $sub->( @extra, @_ ) }; | ||||
389 | if ( my $proto = prototype $sub ) { | ||||
390 | |||||
391 | # XXX - Perl's prototype sucks. Use & to make set_prototype | ||||
392 | # ignore the fact that we're passing "private variables" | ||||
393 | &Scalar::Util::set_prototype( $wrapper, $proto ); | ||||
394 | } | ||||
395 | return $wrapper; | ||||
396 | } | ||||
397 | |||||
398 | # spent 644µs within Moose::Exporter::_late_curry_wrapper which was called 176 times, avg 4µs/call:
# 176 times (644µs+0s) by Moose::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Exporter.pm:379] at line 369, avg 4µs/call | ||||
399 | 176 | 19µs | my $class = shift; | ||
400 | 176 | 13µs | my $sub = shift; | ||
401 | 176 | 18µs | my $fq_name = shift; | ||
402 | 176 | 4µs | my $extra = shift; | ||
403 | 176 | 57µs | my @ex_args = @_; | ||
404 | |||||
405 | my $wrapper = sub { | ||||
406 | |||||
407 | # resolve curried arguments at runtime via this closure | ||||
408 | 60 | 77µs | 60 | 363µs | my @curry = ( $extra->(@ex_args) ); # spent 363µs making 60 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:252], avg 6µs/call |
409 | 60 | 207µs | 60 | 414ms | return $sub->( @curry, @_ ); # spent 257ms making 2 calls to Moose::with, avg 129ms/call
# spent 121ms making 11 calls to Moose::Role::with, avg 11.0ms/call, recursion: max depth 2, sum of overlapping time 38.0ms
# spent 68.5ms making 9 calls to Moose::has, avg 7.61ms/call
# spent 4.90ms making 19 calls to Moose::Role::has, avg 258µs/call
# spent 533µs making 1 call to Moose::extends
# spent 241µs making 6 calls to Moose::Role::requires, avg 40µs/call
# spent 154µs making 6 calls to Moose::Role::around, avg 26µs/call
# spent 92µs making 3 calls to Moose::Role::override, avg 30µs/call
# spent 60µs making 2 calls to Moose::Role::before, avg 30µs/call
# spent 28µs making 1 call to Moose::Role::after |
410 | 176 | 292µs | }; | ||
411 | |||||
412 | 176 | 22µs | if ( my $proto = prototype $sub ) { | ||
413 | |||||
414 | # XXX - Perl's prototype sucks. Use & to make set_prototype | ||||
415 | # ignore the fact that we're passing "private variables" | ||||
416 | &Scalar::Util::set_prototype( $wrapper, $proto ); | ||||
417 | } | ||||
418 | 176 | 334µs | return $wrapper; | ||
419 | } | ||||
420 | |||||
421 | # spent 21µs within Moose::Exporter::_make_import_sub which was called 3 times, avg 7µs/call:
# 3 times (21µs+0s) by Moose::Exporter::build_import_methods at line 65, avg 7µs/call | ||||
422 | 3 | 300ns | shift; | ||
423 | 3 | 800ns | my $exporting_package = shift; | ||
424 | 3 | 800ns | my $exporter = shift; | ||
425 | 3 | 300ns | my $exports_from = shift; | ||
426 | 3 | 400ns | my $is_reexport = shift; | ||
427 | 3 | 300ns | my $meta_lookup = shift; | ||
428 | |||||
429 | # spent 69.0ms (845µs+68.2) within Moose::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Exporter.pm:519] which was called 26 times, avg 2.66ms/call:
# once (29µs+6.14ms) by MooseX::Storage::Engine::BEGIN@8 at line 8 of MooseX/Storage/Engine.pm
# once (34µs+6.13ms) by MooseX::Storage::Meta::Attribute::Trait::DoNotSerialize::BEGIN@9 at line 9 of MooseX/Storage/Meta/Attribute/Trait/DoNotSerialize.pm
# once (30µs+5.78ms) by Moose::Meta::Method::Accessor::Native::Array::BEGIN@12 at line 12 of Moose/Meta/Method/Accessor/Native/Array.pm
# once (34µs+5.49ms) by MooseX::Storage::BEGIN@10 at line 10 of MooseX/Storage.pm
# once (32µs+5.47ms) by Moose::Meta::Method::Accessor::Native::Array::Writer::BEGIN@12 at line 12 of Moose/Meta/Method/Accessor/Native/Array/Writer.pm
# once (44µs+3.41ms) by Atom::BEGIN@2 at line 2 of lib/HackaMol/Atom.pm
# once (30µs+2.78ms) by MooseX::Storage::Meta::Attribute::DoNotSerialize::BEGIN@8 at line 8 of MooseX/Storage/Meta/Attribute/DoNotSerialize.pm
# once (43µs+2.15ms) by Moose::Meta::Method::Accessor::Native::Array::clear::BEGIN@12 at line 12 of Moose/Meta/Method/Accessor/Native/Array/clear.pm
# once (42µs+2.01ms) by Moose::Meta::Method::Accessor::Native::Array::delete::BEGIN@12 at line 12 of Moose/Meta/Method/Accessor/Native/Array/delete.pm
# once (31µs+1.89ms) by Moose::Meta::Method::Accessor::Native::Array::push::BEGIN@12 at line 12 of Moose/Meta/Method/Accessor/Native/Array/push.pm
# once (34µs+1.86ms) by Moose::Meta::Attribute::Native::Trait::Array::BEGIN@9 at line 9 of Moose/Meta/Attribute/Native/Trait/Array.pm
# once (31µs+1.84ms) by Moose::Meta::Method::Accessor::Native::Array::count::BEGIN@12 at line 12 of Moose/Meta/Method/Accessor/Native/Array/count.pm
# once (31µs+1.82ms) by Moose::Meta::Method::Accessor::Native::Array::set::BEGIN@12 at line 12 of Moose/Meta/Method/Accessor/Native/Array/set.pm
# once (31µs+1.82ms) by MooseX::Storage::IO::StorableFile::BEGIN@8 at line 8 of MooseX/Storage/IO/StorableFile.pm
# once (31µs+1.82ms) by Moose::Meta::Method::Accessor::Native::Array::get::BEGIN@14 at line 14 of Moose/Meta/Method/Accessor/Native/Array/get.pm
# once (30µs+1.82ms) by Moose::Meta::Method::Accessor::Native::Array::elements::BEGIN@12 at line 12 of Moose/Meta/Method/Accessor/Native/Array/elements.pm
# once (29µs+1.80ms) by Moose::Meta::Method::Accessor::Native::Collection::BEGIN@12 at line 12 of Moose/Meta/Method/Accessor/Native/Collection.pm
# once (32µs+1.80ms) by PhysVecRole::BEGIN@3 at line 3 of lib/roles/PhysVecRole.pm
# once (29µs+1.79ms) by Moose::Meta::Method::Accessor::Native::Writer::BEGIN@15 at line 15 of Moose/Meta/Method/Accessor/Native/Writer.pm
# once (29µs+1.78ms) by Moose::Meta::Method::Accessor::Native::Reader::BEGIN@12 at line 12 of Moose/Meta/Method/Accessor/Native/Reader.pm
# once (30µs+1.78ms) by Moose::Meta::Attribute::Native::Trait::BEGIN@9 at line 9 of Moose/Meta/Attribute/Native/Trait.pm
# once (30µs+1.76ms) by MooseX::Storage::Basic::BEGIN@8 at line 8 of MooseX/Storage/Basic.pm
# once (30µs+1.74ms) by Moose::Meta::Method::Accessor::Native::BEGIN@15 at line 15 of Moose/Meta/Method/Accessor/Native.pm
# once (27µs+1.27ms) by Moose::Meta::Attribute::Native::Trait::BEGIN@15 at line 15 of Moose/Meta/Attribute/Native/Trait.pm
# once (48µs+1.17ms) by Moose::BEGIN@43 at line 43 of Moose.pm
# once (27µs+1.08ms) by Moose::Role::BEGIN@22 at line 22 of Moose/Role.pm | ||||
430 | |||||
431 | # I think we could use Sub::Exporter's collector feature | ||||
432 | # to do this, but that would be rather gross, since that | ||||
433 | # feature isn't really designed to return a value to the | ||||
434 | # caller of the exporter sub. | ||||
435 | # | ||||
436 | # Also, this makes sure we preserve backwards compat for | ||||
437 | # _get_caller, so it always sees the arguments in the | ||||
438 | # expected order. | ||||
439 | 26 | 2µs | my $traits; | ||
440 | 26 | 50µs | 26 | 265µs | ( $traits, @_ ) = _strip_traits(@_); # spent 265µs making 26 calls to Moose::Exporter::_strip_traits, avg 10µs/call |
441 | |||||
442 | 26 | 1µs | my $metaclass; | ||
443 | 26 | 46µs | 26 | 167µs | ( $metaclass, @_ ) = _strip_metaclass(@_); # spent 167µs making 26 calls to Moose::Exporter::_strip_metaclass, avg 6µs/call |
444 | 26 | 4µs | $metaclass | ||
445 | = Moose::Util::resolve_metaclass_alias( 'Class' => $metaclass ) | ||||
446 | if defined $metaclass && length $metaclass; | ||||
447 | |||||
448 | 26 | 600ns | my $meta_name; | ||
449 | 26 | 51µs | 26 | 157µs | ( $meta_name, @_ ) = _strip_meta_name(@_); # spent 157µs making 26 calls to Moose::Exporter::_strip_meta_name, avg 6µs/call |
450 | |||||
451 | # Normally we could look at $_[0], but in some weird cases | ||||
452 | # (involving goto &Moose::import), $_[0] ends as something | ||||
453 | # else (like Squirrel). | ||||
454 | 26 | 5µs | my $class = $exporting_package; | ||
455 | |||||
456 | 26 | 27µs | 26 | 48µs | $CALLER = _get_caller(@_); # spent 48µs making 26 calls to Moose::Exporter::_get_caller, avg 2µs/call |
457 | |||||
458 | # this works because both pragmas set $^H (see perldoc | ||||
459 | # perlvar) which affects the current compilation - | ||||
460 | # i.e. the file who use'd us - which is why we don't need | ||||
461 | # to do anything special to make it affect that file | ||||
462 | # rather than this one (which is already compiled) | ||||
463 | |||||
464 | 26 | 26µs | 26 | 240µs | strict->import; # spent 240µs making 26 calls to strict::import, avg 9µs/call |
465 | 26 | 23µs | 26 | 100µs | warnings->import; # spent 100µs making 26 calls to warnings::import, avg 4µs/call |
466 | |||||
467 | 26 | 1µs | my $did_init_meta; | ||
468 | 52 | 138µs | 26 | 46µs | for my $c ( grep { $_->can('init_meta') } $class, @{$exports_from} ) { # spent 46µs making 26 calls to UNIVERSAL::can, avg 2µs/call |
469 | |||||
470 | # init_meta can apply a role, which when loaded uses | ||||
471 | # Moose::Exporter, which in turn sets $CALLER, so we need | ||||
472 | # to protect against that. | ||||
473 | 23 | 5µs | local $CALLER = $CALLER; | ||
474 | 23 | 23µs | 23 | 36.5ms | $c->init_meta( # spent 21.9ms making 19 calls to Moose::Role::init_meta, avg 1.15ms/call
# spent 14.5ms making 4 calls to Moose::init_meta, avg 3.64ms/call |
475 | for_class => $CALLER, | ||||
476 | metaclass => $metaclass, | ||||
477 | meta_name => $meta_name, | ||||
478 | ); | ||||
479 | 23 | 18µs | $did_init_meta = 1; | ||
480 | } | ||||
481 | |||||
482 | { | ||||
483 | # The metaroles will use Moose::Role, which in turn uses | ||||
484 | # Moose::Exporter, which in turn sets $CALLER, so we need | ||||
485 | # to protect against that. | ||||
486 | 52 | 17µs | local $CALLER = $CALLER; | ||
487 | 26 | 39µs | 26 | 720µs | _apply_metaroles( # spent 720µs making 26 calls to Moose::Exporter::_apply_metaroles, avg 28µs/call |
488 | $CALLER, | ||||
489 | [$class, @$exports_from], | ||||
490 | $meta_lookup | ||||
491 | ); | ||||
492 | } | ||||
493 | |||||
494 | 26 | 9µs | if ( $did_init_meta && @{$traits} ) { | ||
495 | |||||
496 | # The traits will use Moose::Role, which in turn uses | ||||
497 | # Moose::Exporter, which in turn sets $CALLER, so we need | ||||
498 | # to protect against that. | ||||
499 | local $CALLER = $CALLER; | ||||
500 | _apply_meta_traits( $CALLER, $traits, $meta_lookup ); | ||||
501 | } | ||||
502 | elsif ( @{$traits} ) { | ||||
503 | require Moose; | ||||
504 | Moose->throw_error( | ||||
505 | "Cannot provide traits when $class does not have an init_meta() method" | ||||
506 | ); | ||||
507 | } | ||||
508 | |||||
509 | 26 | 13µs | my ( undef, @args ) = @_; | ||
510 | 26 | 7µs | my $extra = shift @args if ref $args[0] eq 'HASH'; | ||
511 | |||||
512 | 26 | 4µs | $extra ||= {}; | ||
513 | 26 | 8µs | if ( !$extra->{into} ) { | ||
514 | 26 | 11µs | $extra->{into_level} ||= 0; | ||
515 | 26 | 6µs | $extra->{into_level}++; | ||
516 | } | ||||
517 | |||||
518 | 26 | 129µs | 26 | 30.0ms | $class->$exporter( $extra, @args ); # spent 30.0ms making 26 calls to Sub::Exporter::__ANON__[Sub/Exporter.pm:337], avg 1.15ms/call |
519 | 3 | 18µs | }; | ||
520 | } | ||||
521 | |||||
522 | # spent 265µs (181+84) within Moose::Exporter::_strip_traits which was called 26 times, avg 10µs/call:
# 26 times (181µs+84µs) by Moose::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Exporter.pm:519] at line 440, avg 10µs/call | ||||
523 | 53 | 210µs | 26 | 84µs | my $idx = first_index { ( $_ || '' ) eq '-traits' } @_; # spent 84µs making 26 calls to List::MoreUtils::firstidx, avg 3µs/call |
524 | |||||
525 | 26 | 75µs | return ( [], @_ ) unless $idx >= 0 && $#_ >= $idx + 1; | ||
526 | |||||
527 | my $traits = $_[ $idx + 1 ]; | ||||
528 | |||||
529 | splice @_, $idx, 2; | ||||
530 | |||||
531 | $traits = [$traits] unless ref $traits; | ||||
532 | |||||
533 | return ( $traits, @_ ); | ||||
534 | } | ||||
535 | |||||
536 | # spent 167µs (127+40) within Moose::Exporter::_strip_metaclass which was called 26 times, avg 6µs/call:
# 26 times (127µs+40µs) by Moose::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Exporter.pm:519] at line 443, avg 6µs/call | ||||
537 | 53 | 122µs | 26 | 40µs | my $idx = first_index { ( $_ || '' ) eq '-metaclass' } @_; # spent 40µs making 26 calls to List::MoreUtils::firstidx, avg 2µs/call |
538 | |||||
539 | 26 | 57µs | return ( undef, @_ ) unless $idx >= 0 && $#_ >= $idx + 1; | ||
540 | |||||
541 | my $metaclass = $_[ $idx + 1 ]; | ||||
542 | |||||
543 | splice @_, $idx, 2; | ||||
544 | |||||
545 | return ( $metaclass, @_ ); | ||||
546 | } | ||||
547 | |||||
548 | # spent 157µs (120+37) within Moose::Exporter::_strip_meta_name which was called 26 times, avg 6µs/call:
# 26 times (120µs+37µs) by Moose::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Exporter.pm:519] at line 449, avg 6µs/call | ||||
549 | 53 | 112µs | 26 | 37µs | my $idx = first_index { ( $_ || '' ) eq '-meta_name' } @_; # spent 37µs making 26 calls to List::MoreUtils::firstidx, avg 1µs/call |
550 | |||||
551 | 26 | 56µs | return ( 'meta', @_ ) unless $idx >= 0 && $#_ >= $idx + 1; | ||
552 | |||||
553 | my $meta_name = $_[ $idx + 1 ]; | ||||
554 | |||||
555 | splice @_, $idx, 2; | ||||
556 | |||||
557 | return ( $meta_name, @_ ); | ||||
558 | } | ||||
559 | |||||
560 | # spent 720µs (198+522) within Moose::Exporter::_apply_metaroles which was called 26 times, avg 28µs/call:
# 26 times (198µs+522µs) by Moose::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Exporter.pm:519] at line 487, avg 28µs/call | ||||
561 | 26 | 7µs | my ($class, $exports_from, $meta_lookup) = @_; | ||
562 | |||||
563 | 26 | 20µs | 26 | 337µs | my $metaroles = _collect_metaroles($exports_from); # spent 337µs making 26 calls to Moose::Exporter::_collect_metaroles, avg 13µs/call |
564 | 26 | 6µs | my $base_class_roles = delete $metaroles->{base_class_roles}; | ||
565 | |||||
566 | 26 | 27µs | 26 | 156µs | my $meta = $meta_lookup->($class); # spent 156µs making 26 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:42], avg 6µs/call |
567 | # for instance, Moose.pm uses Moose::Util::TypeConstraints | ||||
568 | 26 | 7µs | return unless $meta; | ||
569 | |||||
570 | 24 | 8µs | Moose::Util::MetaRole::apply_metaroles( | ||
571 | for => $meta, | ||||
572 | %$metaroles, | ||||
573 | ) if keys %$metaroles; | ||||
574 | |||||
575 | 24 | 112µs | 24 | 29µs | Moose::Util::MetaRole::apply_base_class_roles( # spent 29µs making 24 calls to UNIVERSAL::isa, avg 1µs/call |
576 | for => $meta, | ||||
577 | roles => $base_class_roles, | ||||
578 | ) if $meta->isa('Class::MOP::Class') | ||||
579 | && $base_class_roles && @$base_class_roles; | ||||
580 | } | ||||
581 | |||||
582 | # spent 337µs within Moose::Exporter::_collect_metaroles which was called 26 times, avg 13µs/call:
# 26 times (337µs+0s) by Moose::Exporter::_apply_metaroles at line 563, avg 13µs/call | ||||
583 | 26 | 4µs | my ($exports_from) = @_; | ||
584 | |||||
585 | 26 | 97µs | my @old_style_role_types = map { "${_}_roles" } qw( | ||
586 | metaclass | ||||
587 | attribute_metaclass | ||||
588 | method_metaclass | ||||
589 | wrapped_method_metaclass | ||||
590 | instance_metaclass | ||||
591 | constructor_class | ||||
592 | destructor_class | ||||
593 | error_class | ||||
594 | ); | ||||
595 | |||||
596 | 26 | 2µs | my %class_metaroles; | ||
597 | 26 | 900ns | my %role_metaroles; | ||
598 | 26 | 3µs | my @base_class_roles; | ||
599 | 26 | 600ns | my %old_style_roles; | ||
600 | |||||
601 | 26 | 12µs | for my $exporter (@$exports_from) { | ||
602 | 26 | 8µs | my $data = $EXPORT_SPEC{$exporter}; | ||
603 | |||||
604 | 26 | 8µs | if (exists $data->{class_metaroles}) { | ||
605 | for my $type (keys %{ $data->{class_metaroles} }) { | ||||
606 | push @{ $class_metaroles{$type} ||= [] }, | ||||
607 | @{ $data->{class_metaroles}{$type} }; | ||||
608 | } | ||||
609 | } | ||||
610 | |||||
611 | 26 | 6µs | if (exists $data->{role_metaroles}) { | ||
612 | for my $type (keys %{ $data->{role_metaroles} }) { | ||||
613 | push @{ $role_metaroles{$type} ||= [] }, | ||||
614 | @{ $data->{role_metaroles}{$type} }; | ||||
615 | } | ||||
616 | } | ||||
617 | |||||
618 | 26 | 7µs | if (exists $data->{base_class_roles}) { | ||
619 | push @base_class_roles, @{ $data->{base_class_roles} }; | ||||
620 | } | ||||
621 | |||||
622 | 26 | 15µs | for my $type (@old_style_role_types) { | ||
623 | 208 | 34µs | if (exists $data->{$type}) { | ||
624 | push @{ $old_style_roles{$type} ||= [] }, | ||||
625 | @{ $data->{$type} }; | ||||
626 | } | ||||
627 | } | ||||
628 | } | ||||
629 | |||||
630 | return { | ||||
631 | 26 | 90µs | (keys(%class_metaroles) | ||
632 | ? (class_metaroles => \%class_metaroles) | ||||
633 | : ()), | ||||
634 | (keys(%role_metaroles) | ||||
635 | ? (role_metaroles => \%role_metaroles) | ||||
636 | : ()), | ||||
637 | (@base_class_roles | ||||
638 | ? (base_class_roles => \@base_class_roles) | ||||
639 | : ()), | ||||
640 | %old_style_roles, | ||||
641 | }; | ||||
642 | } | ||||
643 | |||||
644 | sub _apply_meta_traits { | ||||
645 | my ( $class, $traits, $meta_lookup ) = @_; | ||||
646 | |||||
647 | return unless @{$traits}; | ||||
648 | |||||
649 | my $meta = $meta_lookup->($class); | ||||
650 | |||||
651 | my $type = $meta->isa('Moose::Meta::Role') ? 'Role' | ||||
652 | : $meta->isa('Class::MOP::Class') ? 'Class' | ||||
653 | : Moose->throw_error('Cannot determine metaclass type for ' | ||||
654 | . 'trait application. Meta isa ' | ||||
655 | . ref $meta); | ||||
656 | |||||
657 | my @resolved_traits = map { | ||||
658 | ref $_ | ||||
659 | ? $_ | ||||
660 | : Moose::Util::resolve_metatrait_alias( $type => $_ ) | ||||
661 | } @$traits; | ||||
662 | |||||
663 | return unless @resolved_traits; | ||||
664 | |||||
665 | my %args = ( for => $class ); | ||||
666 | |||||
667 | if ( $meta->isa('Moose::Meta::Role') ) { | ||||
668 | $args{role_metaroles} = { role => \@resolved_traits }; | ||||
669 | } | ||||
670 | else { | ||||
671 | $args{class_metaroles} = { class => \@resolved_traits }; | ||||
672 | } | ||||
673 | |||||
674 | Moose::Util::MetaRole::apply_metaroles(%args); | ||||
675 | } | ||||
676 | |||||
677 | # spent 48µs within Moose::Exporter::_get_caller which was called 26 times, avg 2µs/call:
# 26 times (48µs+0s) by Moose::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Exporter.pm:519] at line 456, avg 2µs/call | ||||
678 | |||||
679 | # 1 extra level because it's called by import so there's a layer | ||||
680 | # of indirection | ||||
681 | 26 | 3µs | my $offset = 1; | ||
682 | |||||
683 | return | ||||
684 | 26 | 65µs | ( ref $_[1] && defined $_[1]->{into} ) ? $_[1]->{into} | ||
685 | : ( ref $_[1] && defined $_[1]->{into_level} ) | ||||
686 | ? caller( $offset + $_[1]->{into_level} ) | ||||
687 | : caller($offset); | ||||
688 | } | ||||
689 | |||||
690 | # spent 15µs within Moose::Exporter::_make_unimport_sub which was called 3 times, avg 5µs/call:
# 3 times (15µs+0s) by Moose::Exporter::build_import_methods at line 73, avg 5µs/call | ||||
691 | 3 | 500ns | shift; | ||
692 | 3 | 600ns | my $exporting_package = shift; | ||
693 | 3 | 1µs | my $exports = shift; | ||
694 | 3 | 500ns | my $export_recorder = shift; | ||
695 | 3 | 600ns | my $is_reexport = shift; | ||
696 | 3 | 800ns | my $meta_lookup = shift; | ||
697 | |||||
698 | # spent 1.29ms (115µs+1.18) within Moose::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Exporter.pm:706] which was called 17 times, avg 76µs/call:
# once (8µs+84µs) by Moose::Meta::Method::Accessor::Native::Array::clear::BEGIN@31 at line 31 of Moose/Meta/Method/Accessor/Native/Array/clear.pm
# once (7µs+81µs) by Moose::Meta::Method::Accessor::Native::Array::delete::BEGIN@53 at line 53 of Moose/Meta/Method/Accessor/Native/Array/delete.pm
# once (6µs+76µs) by Moose::Meta::Method::Accessor::Native::Array::push::BEGIN@39 at line 39 of Moose/Meta/Method/Accessor/Native/Array/push.pm
# once (6µs+74µs) by Moose::Meta::Method::Accessor::Native::Array::set::BEGIN@67 at line 67 of Moose/Meta/Method/Accessor/Native/Array/set.pm
# once (6µs+73µs) by Moose::Meta::Method::Accessor::Native::Array::count::BEGIN@25 at line 25 of Moose/Meta/Method/Accessor/Native/Array/count.pm
# once (8µs+71µs) by Moose::Meta::Method::Accessor::Native::Array::BEGIN@30 at line 30 of Moose/Meta/Method/Accessor/Native/Array.pm
# once (6µs+72µs) by Moose::Meta::Attribute::Native::Trait::Array::BEGIN@15 at line 15 of Moose/Meta/Attribute/Native/Trait/Array.pm
# once (6µs+71µs) by Moose::Meta::Method::Accessor::Native::Collection::BEGIN@168 at line 168 of Moose/Meta/Method/Accessor/Native/Collection.pm
# once (6µs+71µs) by Moose::Meta::Method::Accessor::Native::Array::elements::BEGIN@25 at line 25 of Moose/Meta/Method/Accessor/Native/Array/elements.pm
# once (8µs+69µs) by Moose::Meta::Method::Accessor::Native::Writer::BEGIN@176 at line 176 of Moose/Meta/Method/Accessor/Native/Writer.pm
# once (8µs+68µs) by MooseX::Storage::IO::StorableFile::BEGIN@33 at line 33 of MooseX/Storage/IO/StorableFile.pm
# once (6µs+69µs) by Moose::Meta::Method::Accessor::Native::Reader::BEGIN@50 at line 50 of Moose/Meta/Method/Accessor/Native/Reader.pm
# once (6µs+65µs) by MooseX::Storage::Basic::BEGIN@61 at line 61 of MooseX/Storage/Basic.pm
# once (6µs+65µs) by Moose::Meta::Method::Accessor::Native::BEGIN@164 at line 164 of Moose/Meta/Method/Accessor/Native.pm
# once (7µs+62µs) by Moose::Meta::Attribute::Native::Trait::BEGIN@231 at line 231 of Moose/Meta/Attribute/Native/Trait.pm
# once (6µs+62µs) by Moose::Meta::Attribute::Native::Trait::BEGIN@230 at line 230 of Moose/Meta/Attribute/Native/Trait.pm
# once (10µs+45µs) by MooseX::Storage::Engine::BEGIN@365 at line 365 of MooseX/Storage/Engine.pm | ||||
699 | 17 | 10µs | my $caller = scalar caller(); | ||
700 | Moose::Exporter->_remove_keywords( | ||||
701 | $caller, | ||||
702 | 17 | 115µs | 17 | 1.18ms | [ keys %{$exports} ], # spent 1.18ms making 17 calls to Moose::Exporter::_remove_keywords, avg 69µs/call |
703 | $export_recorder, | ||||
704 | $is_reexport, | ||||
705 | ); | ||||
706 | 3 | 14µs | }; | ||
707 | } | ||||
708 | |||||
709 | # spent 1.18ms (1.15+23µs) within Moose::Exporter::_remove_keywords which was called 17 times, avg 69µs/call:
# 17 times (1.15ms+23µs) by Moose::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Exporter.pm:706] at line 702, avg 69µs/call | ||||
710 | 17 | 1µs | shift; | ||
711 | 17 | 2µs | my $package = shift; | ||
712 | 17 | 2µs | my $keywords = shift; | ||
713 | 17 | 800ns | my $recorded_exports = shift; | ||
714 | 17 | 900ns | my $is_reexport = shift; | ||
715 | |||||
716 | 2 | 61µs | 2 | 28µs | # spent 19µs (9+10) within Moose::Exporter::BEGIN@716 which was called:
# once (9µs+10µs) by Moose::BEGIN@18 at line 716 # spent 19µs making 1 call to Moose::Exporter::BEGIN@716
# spent 10µs making 1 call to strict::unimport |
717 | |||||
718 | 17 | 43µs | foreach my $name ( @{$keywords} ) { | ||
719 | 243 | 207µs | if ( defined &{ $package . '::' . $name } ) { | ||
720 | 241 | 167µs | my $sub = \&{ $package . '::' . $name }; | ||
721 | |||||
722 | # make sure it is from us | ||||
723 | 241 | 74µs | next unless $recorded_exports->{$sub}; | ||
724 | |||||
725 | 231 | 26µs | if ( $is_reexport->{$name} ) { | ||
726 | 2 | 320µs | 2 | 22µs | # spent 14µs (6+8) within Moose::Exporter::BEGIN@726 which was called:
# once (6µs+8µs) by Moose::BEGIN@18 at line 726 # spent 14µs making 1 call to Moose::Exporter::BEGIN@726
# spent 8µs making 1 call to strict::unimport |
727 | next | ||||
728 | unless _export_is_flagged( | ||||
729 | 32 | 118µs | 32 | 23µs | \*{ join q{::} => $package, $name } ); # spent 23µs making 32 calls to Moose::Exporter::_export_is_flagged, avg 725ns/call |
730 | } | ||||
731 | |||||
732 | # and if it is from us, then undef the slot | ||||
733 | 229 | 415µs | delete ${ $package . '::' }{$name}; | ||
734 | } | ||||
735 | } | ||||
736 | } | ||||
737 | |||||
738 | # maintain this for now for backcompat | ||||
739 | # make sure to return a sub to install in the same circumstances as previously | ||||
740 | # but this functionality now happens at the end of ->import | ||||
741 | # spent 40µs within Moose::Exporter::_make_init_meta which was called 3 times, avg 13µs/call:
# 3 times (40µs+0s) by Moose::Exporter::build_import_methods at line 81, avg 13µs/call | ||||
742 | 3 | 300ns | shift; | ||
743 | 3 | 700ns | my $class = shift; | ||
744 | 3 | 1µs | my $args = shift; | ||
745 | 3 | 500ns | my $meta_lookup = shift; | ||
746 | |||||
747 | 3 | 300ns | my %old_style_roles; | ||
748 | 3 | 13µs | for my $role ( | ||
749 | map {"${_}_roles"} | ||||
750 | qw( | ||||
751 | metaclass | ||||
752 | attribute_metaclass | ||||
753 | method_metaclass | ||||
754 | wrapped_method_metaclass | ||||
755 | instance_metaclass | ||||
756 | constructor_class | ||||
757 | destructor_class | ||||
758 | error_class | ||||
759 | ) | ||||
760 | ) { | ||||
761 | 24 | 5µs | $old_style_roles{$role} = $args->{$role} | ||
762 | if exists $args->{$role}; | ||||
763 | } | ||||
764 | |||||
765 | 3 | 300ns | my %base_class_roles; | ||
766 | 3 | 1µs | %base_class_roles = ( roles => $args->{base_class_roles} ) | ||
767 | if exists $args->{base_class_roles}; | ||||
768 | |||||
769 | my %new_style_roles = map { $_ => $args->{$_} } | ||||
770 | 3 | 4µs | grep { exists $args->{$_} } qw( class_metaroles role_metaroles ); | ||
771 | |||||
772 | 3 | 8µs | return unless %new_style_roles || %old_style_roles || %base_class_roles; | ||
773 | |||||
774 | return sub { | ||||
775 | shift; | ||||
776 | my %opts = @_; | ||||
777 | $meta_lookup->($opts{for_class}); | ||||
778 | }; | ||||
779 | } | ||||
780 | |||||
781 | # spent 63µs (22+41) within Moose::Exporter::import which was called 3 times, avg 21µs/call:
# once (11µs+15µs) by Moose::BEGIN@18 at line 18 of Moose.pm
# once (6µs+14µs) by Moose::Role::BEGIN@20 at line 20 of Moose/Role.pm
# once (6µs+12µs) by Moose::Util::TypeConstraints::BEGIN@13 at line 13 of Moose/Util/TypeConstraints.pm | ||||
782 | 3 | 3µs | 3 | 28µs | strict->import; # spent 28µs making 3 calls to strict::import, avg 10µs/call |
783 | 3 | 11µs | 3 | 13µs | warnings->import; # spent 13µs making 3 calls to warnings::import, avg 4µs/call |
784 | } | ||||
785 | |||||
786 | 1 | 3µs | 1; | ||
787 | |||||
788 | # ABSTRACT: make an import() and unimport() just like Moose.pm | ||||
789 | |||||
790 | __END__ | ||||
# spent 23µs within Moose::Exporter::_export_is_flagged which was called 32 times, avg 725ns/call:
# 32 times (23µs+0s) by Moose::Exporter::_remove_keywords at line 729, avg 725ns/call | |||||
# spent 41µs within Moose::Exporter::_flag_as_reexport which was called 43 times, avg 944ns/call:
# 43 times (41µs+0s) by Moose::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Exporter.pm:137] at line 135, avg 944ns/call |